about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2020-12-01 21:37:45 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2021-06-29 19:23:38 +0200
commitf51c57fb7abf801a5bc29b3bb487c7eb5c7ffe9d (patch)
treead1780e906d9c1f2c3b2a4b6cc032eb89d2128dc
parent8971fff984e7a45ca6cdcd146816b4896a4ab1ea (diff)
downloadrust-f51c57fb7abf801a5bc29b3bb487c7eb5c7ffe9d.tar.gz
rust-f51c57fb7abf801a5bc29b3bb487c7eb5c7ffe9d.zip
Use the macro to implement HashStable.
-rw-r--r--compiler/rustc_middle/src/lint.rs28
1 files changed, 3 insertions, 25 deletions
diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs
index 7ac7720a7c5..7461979a9fe 100644
--- a/compiler/rustc_middle/src/lint.rs
+++ b/compiler/rustc_middle/src/lint.rs
@@ -51,13 +51,13 @@ impl LintLevelSource {
 /// A tuple of a lint level and its source.
 pub type LevelAndSource = (Level, LintLevelSource);
 
-#[derive(Debug)]
+#[derive(Debug, HashStable)]
 pub struct LintLevelSets {
     pub list: Vec<LintSet>,
     pub lint_cap: Level,
 }
 
-#[derive(Debug)]
+#[derive(Debug, HashStable)]
 pub enum LintSet {
     CommandLine {
         // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
@@ -180,29 +180,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for LintLevelMap {
 
         id_to_set.hash_stable(hcx, hasher);
 
-        let LintLevelSets { ref list, lint_cap } = *sets;
-
-        lint_cap.hash_stable(hcx, hasher);
-
-        hcx.while_hashing_spans(true, |hcx| {
-            list.len().hash_stable(hcx, hasher);
-
-            // We are working under the assumption here that the list of
-            // lint-sets is built in a deterministic order.
-            for lint_set in list {
-                ::std::mem::discriminant(lint_set).hash_stable(hcx, hasher);
-
-                match *lint_set {
-                    LintSet::CommandLine { ref specs } => {
-                        specs.hash_stable(hcx, hasher);
-                    }
-                    LintSet::Node { ref specs, parent } => {
-                        specs.hash_stable(hcx, hasher);
-                        parent.hash_stable(hcx, hasher);
-                    }
-                }
-            }
-        })
+        hcx.while_hashing_spans(true, |hcx| sets.hash_stable(hcx, hasher))
     }
 }