Skip to content

Commit f51c57f

Browse files
committed
Use the macro to implement HashStable.
1 parent 8971fff commit f51c57f

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

compiler/rustc_middle/src/lint.rs

+3-25
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ impl LintLevelSource {
5151
/// A tuple of a lint level and its source.
5252
pub type LevelAndSource = (Level, LintLevelSource);
5353

54-
#[derive(Debug)]
54+
#[derive(Debug, HashStable)]
5555
pub struct LintLevelSets {
5656
pub list: Vec<LintSet>,
5757
pub lint_cap: Level,
5858
}
5959

60-
#[derive(Debug)]
60+
#[derive(Debug, HashStable)]
6161
pub enum LintSet {
6262
CommandLine {
6363
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
@@ -180,29 +180,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for LintLevelMap {
180180

181181
id_to_set.hash_stable(hcx, hasher);
182182

183-
let LintLevelSets { ref list, lint_cap } = *sets;
184-
185-
lint_cap.hash_stable(hcx, hasher);
186-
187-
hcx.while_hashing_spans(true, |hcx| {
188-
list.len().hash_stable(hcx, hasher);
189-
190-
// We are working under the assumption here that the list of
191-
// lint-sets is built in a deterministic order.
192-
for lint_set in list {
193-
::std::mem::discriminant(lint_set).hash_stable(hcx, hasher);
194-
195-
match *lint_set {
196-
LintSet::CommandLine { ref specs } => {
197-
specs.hash_stable(hcx, hasher);
198-
}
199-
LintSet::Node { ref specs, parent } => {
200-
specs.hash_stable(hcx, hasher);
201-
parent.hash_stable(hcx, hasher);
202-
}
203-
}
204-
}
205-
})
183+
hcx.while_hashing_spans(true, |hcx| sets.hash_stable(hcx, hasher))
206184
}
207185
}
208186

0 commit comments

Comments
 (0)