]> git.lizzy.rs Git - rust.git/commitdiff
Use Vec for expectations to have a constant order (RFC-2383)
authorxFrednet <xFrednet@gmail.com>
Wed, 2 Mar 2022 17:10:07 +0000 (18:10 +0100)
committerxFrednet <xFrednet@gmail.com>
Wed, 2 Mar 2022 17:10:07 +0000 (18:10 +0100)
compiler/rustc_lint/src/expect.rs
compiler/rustc_lint/src/levels.rs
compiler/rustc_middle/src/lint.rs
src/test/ui/lint/rfc-2383-lint-reason/expect_multiple_lints.stderr
src/test/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.rs
src/test/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr

index 7611b41b97eace2167914abba953bee246c3b026..e6c9d0b0ab000790cbd7bab015df5e5e0febe80e 100644 (file)
@@ -1,5 +1,4 @@
 use crate::builtin;
-use rustc_data_structures::fx::FxHashMap;
 use rustc_hir::HirId;
 use rustc_middle::{lint::LintExpectation, ty::TyCtxt};
 use rustc_session::lint::LintExpectationId;
@@ -11,8 +10,7 @@ pub fn check_expectations(tcx: TyCtxt<'_>) {
     }
 
     let fulfilled_expectations = tcx.sess.diagnostic().steal_fulfilled_expectation_ids();
-    let lint_expectations: &FxHashMap<LintExpectationId, LintExpectation> =
-        &tcx.lint_levels(()).lint_expectations;
+    let lint_expectations = &tcx.lint_levels(()).lint_expectations;
 
     for (id, expectation) in lint_expectations {
         if !fulfilled_expectations.contains(id) {
index f40abff7fc059fb9881940e0dd17eda5e5ac9064..f46f74fa45fb044c7775d7e0ae37dfc490c9f104 100644 (file)
@@ -45,7 +45,7 @@ fn lint_levels(tcx: TyCtxt<'_>, (): ()) -> LintLevelMap {
 
 pub struct LintLevelsBuilder<'s> {
     sess: &'s Session,
-    lint_expectations: FxHashMap<LintExpectationId, LintExpectation>,
+    lint_expectations: Vec<(LintExpectationId, LintExpectation)>,
     /// Each expectation has a stable and an unstable identifier. This map
     /// is used to map from unstable to stable [`LintExpectationId`]s.
     expectation_id_map: FxHashMap<LintExpectationId, LintExpectationId>,
@@ -355,7 +355,7 @@ pub(crate) fn push(
                         }
                         if let Level::Expect(expect_id) = level {
                             self.lint_expectations
-                                .insert(expect_id, LintExpectation::new(reason, sp));
+                                .push((expect_id, LintExpectation::new(reason, sp)));
                         }
                     }
 
@@ -374,7 +374,7 @@ pub(crate) fn push(
                                 }
                                 if let Level::Expect(expect_id) = level {
                                     self.lint_expectations
-                                        .insert(expect_id, LintExpectation::new(reason, sp));
+                                        .push((expect_id, LintExpectation::new(reason, sp)));
                                 }
                             }
                             Err((Some(ids), ref new_lint_name)) => {
@@ -414,7 +414,7 @@ pub(crate) fn push(
                                 }
                                 if let Level::Expect(expect_id) = level {
                                     self.lint_expectations
-                                        .insert(expect_id, LintExpectation::new(reason, sp));
+                                        .push((expect_id, LintExpectation::new(reason, sp)));
                                 }
                             }
                             Err((None, _)) => {
@@ -511,7 +511,7 @@ pub(crate) fn push(
                         }
                         if let Level::Expect(expect_id) = level {
                             self.lint_expectations
-                                .insert(expect_id, LintExpectation::new(reason, sp));
+                                .push((expect_id, LintExpectation::new(reason, sp)));
                         }
                     } else {
                         panic!("renamed lint does not exist: {}", new_name);
index cc99e4dfac96d51fbfa0a0cb29d4e4cc5a5cb44a..894947fa70d969506628d27370b25b6fbdcb0745 100644 (file)
@@ -159,7 +159,7 @@ pub struct LintLevelMap {
     ///
     /// The [`LintExpectationId`] is stored as a part of the [`Expect`](Level::Expect)
     /// lint level.
-    pub lint_expectations: FxHashMap<LintExpectationId, LintExpectation>,
+    pub lint_expectations: Vec<(LintExpectationId, LintExpectation)>,
     pub sets: LintLevelSets,
     pub id_to_set: FxHashMap<HirId, LintStackIndex>,
 }
index 25299aa7ec2fc287eb40f843f0a1e37c6310ee7b..90ee744b26b01799416da2bfd8af3e8c10134220 100644 (file)
@@ -7,10 +7,10 @@ LL | #[expect(unused_variables, unused_mut, while_true)]
    = note: `#[warn(unfulfilled_lint_expectations)]` on by default
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_multiple_lints.rs:28:10
+  --> $DIR/expect_multiple_lints.rs:10:40
    |
 LL | #[expect(unused_variables, unused_mut, while_true)]
-   |          ^^^^^^^^^^^^^^^^
+   |                                        ^^^^^^^^^^
 
 warning: this lint expectation is unfulfilled
   --> $DIR/expect_multiple_lints.rs:19:10
@@ -19,34 +19,34 @@ LL | #[expect(unused_variables, unused_mut, while_true)]
    |          ^^^^^^^^^^^^^^^^
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_multiple_lints.rs:28:28
+  --> $DIR/expect_multiple_lints.rs:19:40
    |
 LL | #[expect(unused_variables, unused_mut, while_true)]
-   |                            ^^^^^^^^^^
+   |                                        ^^^^^^^^^^
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_multiple_lints.rs:36:18
+  --> $DIR/expect_multiple_lints.rs:28:10
    |
-LL | #[expect(unused, while_true)]
-   |                  ^^^^^^^^^^
+LL | #[expect(unused_variables, unused_mut, while_true)]
+   |          ^^^^^^^^^^^^^^^^
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_multiple_lints.rs:19:40
+  --> $DIR/expect_multiple_lints.rs:28:28
    |
 LL | #[expect(unused_variables, unused_mut, while_true)]
-   |                                        ^^^^^^^^^^
+   |                            ^^^^^^^^^^
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_multiple_lints.rs:45:10
+  --> $DIR/expect_multiple_lints.rs:36:18
    |
 LL | #[expect(unused, while_true)]
-   |          ^^^^^^
+   |                  ^^^^^^^^^^
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_multiple_lints.rs:10:40
+  --> $DIR/expect_multiple_lints.rs:45:10
    |
-LL | #[expect(unused_variables, unused_mut, while_true)]
-   |                                        ^^^^^^^^^^
+LL | #[expect(unused, while_true)]
+   |          ^^^^^^
 
 warning: 8 warnings emitted
 
index cad6b836c7a72fa37bcd8bfb518cc17177c804af..8f94bd6ec6cb81e6d1adda56e820150df9add2e1 100644 (file)
@@ -6,6 +6,7 @@
 #[expect(
     unused_mut,
     //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
+    //~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default
     //~| NOTE this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered
     reason = "this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered"
 )]
@@ -22,7 +23,6 @@ fn bar() {
 #[expect(
     unused_mut,
     //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
-    //~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default
     //~| NOTE this `expect` is overridden by a `warn` attribute before the `unused_mut` lint is triggered
     reason = "this `expect` is overridden by a `warn` attribute before the `unused_mut` lint is triggered"
 )]
index 353cbc341f24a2ea634dae65f3b0032e40690b69..370e51bf70a7a203ddfc92cea79dbcd5e27d2539 100644 (file)
@@ -26,21 +26,21 @@ LL |         unused_mut,
    |         ^^^^^^^^^^
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_nested_lint_levels.rs:23:5
+  --> $DIR/expect_nested_lint_levels.rs:7:5
    |
 LL |     unused_mut,
    |     ^^^^^^^^^^
    |
    = note: `#[warn(unfulfilled_lint_expectations)]` on by default
-   = note: this `expect` is overridden by a `warn` attribute before the `unused_mut` lint is triggered
+   = note: this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered
 
 warning: this lint expectation is unfulfilled
-  --> $DIR/expect_nested_lint_levels.rs:7:5
+  --> $DIR/expect_nested_lint_levels.rs:24:5
    |
 LL |     unused_mut,
    |     ^^^^^^^^^^
    |
-   = note: this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered
+   = note: this `expect` is overridden by a `warn` attribute before the `unused_mut` lint is triggered
 
 warning: this lint expectation is unfulfilled
   --> $DIR/expect_nested_lint_levels.rs:43:10