Skip to content

Commit 5a731ff

Browse files
committed
Encode CommandLine in the index only.
1 parent 66fee06 commit 5a731ff

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

Diff for: compiler/rustc_lint/src/levels.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'s> LintLevelsBuilder<'s> {
121121
}
122122
}
123123

124-
self.cur = self.sets.list.push(LintSet::CommandLine { specs });
124+
self.cur = self.sets.list.push(LintSet { specs, parent: COMMAND_LINE });
125125
}
126126

127127
/// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
@@ -524,7 +524,7 @@ impl<'s> LintLevelsBuilder<'s> {
524524

525525
let prev = self.cur;
526526
if !specs.is_empty() {
527-
self.cur = self.sets.list.push(LintSet::Node { specs, parent: prev });
527+
self.cur = self.sets.list.push(LintSet { specs, parent: prev });
528528
}
529529

530530
BuilderPush { prev, changed: prev != self.cur }

Diff for: compiler/rustc_middle/src/lint.rs

+13-24
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,12 @@ rustc_index::newtype_index! {
6666
}
6767

6868
#[derive(Debug, HashStable)]
69-
pub enum LintSet {
70-
CommandLine {
71-
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
72-
// flag.
73-
specs: FxHashMap<LintId, LevelAndSource>,
74-
},
75-
76-
Node {
77-
specs: FxHashMap<LintId, LevelAndSource>,
78-
parent: LintStackIndex,
79-
},
69+
pub struct LintSet {
70+
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
71+
// flag.
72+
pub specs: FxHashMap<LintId, LevelAndSource>,
73+
74+
pub parent: LintStackIndex,
8075
}
8176

8277
impl LintLevelSets {
@@ -139,20 +134,14 @@ impl LintLevelSets {
139134
}
140135
}
141136
loop {
142-
match self.list[idx] {
143-
LintSet::CommandLine { ref specs } => {
144-
if let Some(&(level, src)) = specs.get(&id) {
145-
return (Some(level), src);
146-
}
147-
return (None, LintLevelSource::Default);
148-
}
149-
LintSet::Node { ref specs, parent } => {
150-
if let Some(&(level, src)) = specs.get(&id) {
151-
return (Some(level), src);
152-
}
153-
idx = parent;
154-
}
137+
let LintSet { ref specs, parent } = self.list[idx];
138+
if let Some(&(level, src)) = specs.get(&id) {
139+
return (Some(level), src);
140+
}
141+
if idx == COMMAND_LINE {
142+
return (None, LintLevelSource::Default);
155143
}
144+
idx = parent;
156145
}
157146
}
158147
}

0 commit comments

Comments
 (0)