diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2020-12-01 21:56:15 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-06-29 20:05:11 +0200 |
| commit | 5a731ffdaefe26f68d0744882390f6c12c4284da (patch) | |
| tree | b5d818bd81bd2f5faea98fbff9d705236939e7b8 | |
| parent | 66fee063b6c9baed90af1e99baf75c651c2a6247 (diff) | |
| download | rust-5a731ffdaefe26f68d0744882390f6c12c4284da.tar.gz rust-5a731ffdaefe26f68d0744882390f6c12c4284da.zip | |
Encode CommandLine in the index only.
| -rw-r--r-- | compiler/rustc_lint/src/levels.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/lint.rs | 37 |
2 files changed, 15 insertions, 26 deletions
diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index d190be24b60..c7e26013f1c 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -121,7 +121,7 @@ impl<'s> LintLevelsBuilder<'s> { } } - 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 @@ impl<'s> LintLevelsBuilder<'s> { 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 } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index bd1817684dc..560581cf641 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -66,17 +66,12 @@ rustc_index::newtype_index! { } #[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 @@ impl LintLevelSets { } } 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; } } } |
