Skip to content

Commit fca0d8a

Browse files
committed
Comment LintLevelSets.
1 parent 69613bb commit fca0d8a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/rustc_lint/src/levels.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ use crate::errors::{
2828
UnknownToolInScopedLint,
2929
};
3030

31+
/// Collection of lint levels for the whole crate.
32+
/// This is used by AST-based lints, which do not
33+
/// wait until we have built HIR to be emitted.
3134
#[derive(Debug)]
3235
struct LintLevelSets {
36+
/// Linked list of specifications.
3337
list: IndexVec<LintStackIndex, LintSet>,
3438
}
3539

@@ -40,12 +44,19 @@ rustc_index::newtype_index! {
4044
}
4145
}
4246

47+
/// Specifications found at this position in the stack. This map only represents the lints
48+
/// found for one set of attributes (like `shallow_lint_levels_on` does).
49+
///
50+
/// We store the level specifications as a linked list.
51+
/// Each `LintSet` represents a set of attributes on the same AST node.
52+
/// The `parent` forms a linked list that matches the AST tree.
53+
/// This way, walking the linked list is equivalent to walking the AST bottom-up
54+
/// to find the specifications for a given lint.
4355
#[derive(Debug)]
4456
struct LintSet {
4557
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
4658
// flag.
4759
specs: FxHashMap<LintId, LevelAndSource>,
48-
4960
parent: LintStackIndex,
5061
}
5162

0 commit comments

Comments
 (0)