about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2022-09-10 10:14:51 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2022-09-14 19:06:30 +0200
commitfca0d8a10e1a74a9a978c816929856a7e196eda2 (patch)
tree9fb9cf644fa82447b7a7ccc69599f5a1c87278d9
parent69613bb60223c97fa994ebb00fc789922cd0a483 (diff)
downloadrust-fca0d8a10e1a74a9a978c816929856a7e196eda2.tar.gz
rust-fca0d8a10e1a74a9a978c816929856a7e196eda2.zip
Comment LintLevelSets.
-rw-r--r--compiler/rustc_lint/src/levels.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs
index eef342d4b07..b5b9312df63 100644
--- a/compiler/rustc_lint/src/levels.rs
+++ b/compiler/rustc_lint/src/levels.rs
@@ -28,8 +28,12 @@ use crate::errors::{
     UnknownToolInScopedLint,
 };
 
+/// Collection of lint levels for the whole crate.
+/// This is used by AST-based lints, which do not
+/// wait until we have built HIR to be emitted.
 #[derive(Debug)]
 struct LintLevelSets {
+    /// Linked list of specifications.
     list: IndexVec<LintStackIndex, LintSet>,
 }
 
@@ -40,12 +44,19 @@ rustc_index::newtype_index! {
     }
 }
 
+/// Specifications found at this position in the stack.  This map only represents the lints
+/// found for one set of attributes (like `shallow_lint_levels_on` does).
+///
+/// We store the level specifications as a linked list.
+/// Each `LintSet` represents a set of attributes on the same AST node.
+/// The `parent` forms a linked list that matches the AST tree.
+/// This way, walking the linked list is equivalent to walking the AST bottom-up
+/// to find the specifications for a given lint.
 #[derive(Debug)]
 struct LintSet {
     // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
     // flag.
     specs: FxHashMap<LintId, LevelAndSource>,
-
     parent: LintStackIndex,
 }