Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup the computation of lint levels #82985

Merged
merged 3 commits into from
Jul 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use the macro to implement HashStable.
  • Loading branch information
cjgillot committed Jun 29, 2021
commit f51c57fb7abf801a5bc29b3bb487c7eb5c7ffe9d
28 changes: 3 additions & 25 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ impl LintLevelSource {
/// A tuple of a lint level and its source.
pub type LevelAndSource = (Level, LintLevelSource);

#[derive(Debug)]
#[derive(Debug, HashStable)]
pub struct LintLevelSets {
pub list: Vec<LintSet>,
pub lint_cap: Level,
}

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

id_to_set.hash_stable(hcx, hasher);

let LintLevelSets { ref list, lint_cap } = *sets;

lint_cap.hash_stable(hcx, hasher);

hcx.while_hashing_spans(true, |hcx| {
list.len().hash_stable(hcx, hasher);

// We are working under the assumption here that the list of
// lint-sets is built in a deterministic order.
for lint_set in list {
::std::mem::discriminant(lint_set).hash_stable(hcx, hasher);

match *lint_set {
LintSet::CommandLine { ref specs } => {
specs.hash_stable(hcx, hasher);
}
LintSet::Node { ref specs, parent } => {
specs.hash_stable(hcx, hasher);
parent.hash_stable(hcx, hasher);
}
}
}
})
hcx.while_hashing_spans(true, |hcx| sets.hash_stable(hcx, hasher))
}
}

Expand Down