]> git.lizzy.rs Git - rust.git/commitdiff
Use the macro to implement HashStable.
authorCamille GILLOT <gillot.camille@gmail.com>
Tue, 1 Dec 2020 20:37:45 +0000 (21:37 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Tue, 29 Jun 2021 17:23:38 +0000 (19:23 +0200)
compiler/rustc_middle/src/lint.rs

index 7ac7720a7c56367afbf09be4eeb1975d2ccf9ff6..7461979a9fe10c99bae91370706c6325a7aad41b 100644 (file)
@@ -51,13 +51,13 @@ pub fn span(&self) -> Span {
 /// 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 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
 
         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))
     }
 }