Struct rustc_lint::levels::LintLevelsBuilder
source · [−]pub struct LintLevelsBuilder<'s> {
sess: &'s Session,
lint_expectations: Vec<(LintExpectationId, LintExpectation)>,
expectation_id_map: FxHashMap<LintExpectationId, LintExpectationId>,
sets: LintLevelSets,
id_to_set: FxHashMap<HirId, LintStackIndex>,
cur: LintStackIndex,
warn_about_weird_lints: bool,
store: &'s LintStore,
registered_tools: &'s RegisteredTools,
}
Fields
sess: &'s Session
lint_expectations: Vec<(LintExpectationId, LintExpectation)>
expectation_id_map: FxHashMap<LintExpectationId, LintExpectationId>
Each expectation has a stable and an unstable identifier. This map
is used to map from unstable to stable LintExpectationId
s.
sets: LintLevelSets
id_to_set: FxHashMap<HirId, LintStackIndex>
cur: LintStackIndex
warn_about_weird_lints: bool
store: &'s LintStore
registered_tools: &'s RegisteredTools
Implementations
sourceimpl<'s> LintLevelsBuilder<'s>
impl<'s> LintLevelsBuilder<'s>
pub fn new(
sess: &'s Session,
warn_about_weird_lints: bool,
store: &'s LintStore,
registered_tools: &'s RegisteredTools
) -> Self
pub(crate) fn sess(&self) -> &Session
pub(crate) fn lint_store(&self) -> &LintStore
fn current_specs(&self) -> &FxHashMap<LintId, LevelAndSource>
fn current_specs_mut(&mut self) -> &mut FxHashMap<LintId, LevelAndSource>
fn process_command_line(&mut self, sess: &Session, store: &LintStore)
sourcefn insert_spec(&mut self, id: LintId, (level, src): LevelAndSource)
fn insert_spec(&mut self, id: LintId, (level, src): LevelAndSource)
Attempts to insert the id
to level_src
map entry. If unsuccessful
(e.g. if a forbid was already inserted on the same scope), then emits a
diagnostic with no change to specs
.
sourcepub(crate) fn push(
&mut self,
attrs: &[Attribute],
is_crate_node: bool,
source_hir_id: Option<HirId>
) -> BuilderPush
pub(crate) fn push(
&mut self,
attrs: &[Attribute],
is_crate_node: bool,
source_hir_id: Option<HirId>
) -> BuilderPush
Pushes a list of AST lint attributes onto this context.
This function will return a BuilderPush
object which should be passed
to pop
when this scope for the attributes provided is exited.
This function will perform a number of tasks:
- It’ll validate all lint-related attributes in
attrs
- It’ll mark all lint-related attributes as used
- Lint levels will be updated based on the attributes provided
- Lint attributes are validated, e.g., a
#[forbid]
can’t be switched to#[allow]
Don’t forget to call pop
!
fn create_stable_id(
&mut self,
unstable_id: LintExpectationId,
hir_id: HirId,
attr_index: usize
) -> LintExpectationId
sourcefn check_gated_lint(&self, lint_id: LintId, span: Span) -> bool
fn check_gated_lint(&self, lint_id: LintId, span: Span) -> bool
Checks if the lint is gated on a feature that is not enabled.
Returns true
if the lint’s feature is enabled.
sourcepub fn pop(&mut self, push: BuilderPush)
pub fn pop(&mut self, push: BuilderPush)
Called after push
when the scope of a set of attributes are exited.
sourcepub fn lint_level(&self, lint: &'static Lint) -> (Level, LintLevelSource)
pub fn lint_level(&self, lint: &'static Lint) -> (Level, LintLevelSource)
Find the lint level for a lint.
sourcepub fn struct_lint(
&self,
lint: &'static Lint,
span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
pub fn struct_lint(
&self,
lint: &'static Lint,
span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
Used to emit a lint-related diagnostic based on the current state of this lint context.
sourcepub fn register_id(&mut self, id: HirId)
pub fn register_id(&mut self, id: HirId)
Registers the ID provided with the current set of lints stored in this context.
fn update_unstable_expectation_ids(&self)
pub fn build_map(self) -> LintLevelMap
Auto Trait Implementations
impl<'s> !RefUnwindSafe for LintLevelsBuilder<'s>
impl<'s> !Send for LintLevelsBuilder<'s>
impl<'s> !Sync for LintLevelsBuilder<'s>
impl<'s> Unpin for LintLevelsBuilder<'s>
impl<'s> !UnwindSafe for LintLevelsBuilder<'s>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 168 bytes