]> git.lizzy.rs Git - rust.git/commitdiff
Encode CommandLine in the index only.
authorCamille GILLOT <gillot.camille@gmail.com>
Tue, 1 Dec 2020 20:56:15 +0000 (21:56 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Tue, 29 Jun 2021 18:05:11 +0000 (20:05 +0200)
compiler/rustc_lint/src/levels.rs
compiler/rustc_middle/src/lint.rs

index d190be24b60a5ab8fa25c2898e9614cf72beb0bb..c7e26013f1cbe1dcb8b224884f842d1b9e1f1743 100644 (file)
@@ -121,7 +121,7 @@ fn process_command_line(&mut self, sess: &Session, store: &LintStore) {
             }
         }
 
-        self.cur = self.sets.list.push(LintSet::CommandLine { specs });
+        self.cur = self.sets.list.push(LintSet { specs, parent: COMMAND_LINE });
     }
 
     /// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
@@ -524,7 +524,7 @@ pub(crate) fn push(
 
         let prev = self.cur;
         if !specs.is_empty() {
-            self.cur = self.sets.list.push(LintSet::Node { specs, parent: prev });
+            self.cur = self.sets.list.push(LintSet { specs, parent: prev });
         }
 
         BuilderPush { prev, changed: prev != self.cur }
index bd1817684dc840f8f5250b1e6801a35080a8d28f..560581cf641a52e2f7e0eff75143b3e4a4bfc023 100644 (file)
@@ -66,17 +66,12 @@ pub struct LintStackIndex {
 }
 
 #[derive(Debug, HashStable)]
-pub enum LintSet {
-    CommandLine {
-        // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
-        // flag.
-        specs: FxHashMap<LintId, LevelAndSource>,
-    },
-
-    Node {
-        specs: FxHashMap<LintId, LevelAndSource>,
-        parent: LintStackIndex,
-    },
+pub struct LintSet {
+    // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
+    // flag.
+    pub specs: FxHashMap<LintId, LevelAndSource>,
+
+    pub parent: LintStackIndex,
 }
 
 impl LintLevelSets {
@@ -139,20 +134,14 @@ pub fn get_lint_id_level(
             }
         }
         loop {
-            match self.list[idx] {
-                LintSet::CommandLine { ref specs } => {
-                    if let Some(&(level, src)) = specs.get(&id) {
-                        return (Some(level), src);
-                    }
-                    return (None, LintLevelSource::Default);
-                }
-                LintSet::Node { ref specs, parent } => {
-                    if let Some(&(level, src)) = specs.get(&id) {
-                        return (Some(level), src);
-                    }
-                    idx = parent;
-                }
+            let LintSet { ref specs, parent } = self.list[idx];
+            if let Some(&(level, src)) = specs.get(&id) {
+                return (Some(level), src);
+            }
+            if idx == COMMAND_LINE {
+                return (None, LintLevelSource::Default);
             }
+            idx = parent;
         }
     }
 }