Skip to content

Commit

Permalink
Encode CommandLine in the index only.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jun 29, 2021
1 parent 66fee06 commit 5a731ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
37 changes: 13 additions & 24 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 5a731ff

Please sign in to comment.