Trait rustc_lint::LintContext
source · [−]pub trait LintContext: Sized {
type PassObject: LintPassObject;
fn sess(&self) -> &Session;
fn lints(&self) -> &LintStore;
fn lookup<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: Option<S>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
);
fn get_lint_level(&self, lint: &'static Lint) -> Level;
fn lookup_with_diagnostics(
&self,
lint: &'static Lint,
span: Option<impl Into<MultiSpan>>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>,
diagnostic: BuiltinLintDiagnostics
) { ... }
fn emit_spanned_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
decorator: impl for<'a> DecorateLint<'a, ()>
) { ... }
fn struct_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
) { ... }
fn emit_lint(
&self,
lint: &'static Lint,
decorator: impl for<'a> DecorateLint<'a, ()>
) { ... }
fn lint(
&self,
lint: &'static Lint,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
) { ... }
fn fulfill_expectation(&self, expectation: LintExpectationId) { ... }
}
Required Associated Types
Required Methods
fn sess(&self) -> &Session
fn lints(&self) -> &LintStore
fn lookup<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: Option<S>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
sourcefn get_lint_level(&self, lint: &'static Lint) -> Level
fn get_lint_level(&self, lint: &'static Lint) -> Level
This returns the lint level for the given lint at the current location.
Provided Methods
fn lookup_with_diagnostics(
&self,
lint: &'static Lint,
span: Option<impl Into<MultiSpan>>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>,
diagnostic: BuiltinLintDiagnostics
)
sourcefn emit_spanned_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
decorator: impl for<'a> DecorateLint<'a, ()>
)
fn emit_spanned_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
decorator: impl for<'a> DecorateLint<'a, ()>
)
Emit a lint at span
from a lint struct (some type that implements DecorateLint
,
typically generated by #[derive(LintDiagnostic)]
).
fn struct_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
sourcefn emit_lint(
&self,
lint: &'static Lint,
decorator: impl for<'a> DecorateLint<'a, ()>
)
fn emit_lint(
&self,
lint: &'static Lint,
decorator: impl for<'a> DecorateLint<'a, ()>
)
Emit a lint from a lint struct (some type that implements DecorateLint
, typically
generated by #[derive(LintDiagnostic)]
).
sourcefn lint(
&self,
lint: &'static Lint,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
fn lint(
&self,
lint: &'static Lint,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
Emit a lint at the appropriate level, with no associated span.
sourcefn fulfill_expectation(&self, expectation: LintExpectationId)
fn fulfill_expectation(&self, expectation: LintExpectationId)
This function can be used to manually fulfill an expectation. This can be used for lints which contain several spans, and should be suppressed, if either location was marked with an expectation.
Note that this function should only be called for LintExpectationId
s
retrieved from the current lint pass. Buffered or manually created ids can
cause ICEs.