rustc_lint

Trait LintContext

Source
pub trait LintContext {
    // Required methods
    fn sess(&self) -> &Session;
    fn opt_span_lint<S: Into<MultiSpan>>(
        &self,
        lint: &'static Lint,
        span: Option<S>,
        decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
    );
    fn get_lint_level(&self, lint: &'static Lint) -> Level;

    // Provided methods
    fn emit_span_lint<S: Into<MultiSpan>>(
        &self,
        lint: &'static Lint,
        span: S,
        decorator: impl for<'a> LintDiagnostic<'a, ()>,
    ) { ... }
    fn span_lint<S: Into<MultiSpan>>(
        &self,
        lint: &'static Lint,
        span: S,
        decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
    ) { ... }
    fn emit_lint(
        &self,
        lint: &'static Lint,
        decorator: impl for<'a> LintDiagnostic<'a, ()>,
    ) { ... }
    fn lint(
        &self,
        lint: &'static Lint,
        decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
    ) { ... }
    fn fulfill_expectation(&self, expectation: LintExpectationId) { ... }
}

Required Methods§

Source

fn sess(&self) -> &Session

Source

fn opt_span_lint<S: Into<MultiSpan>>( &self, lint: &'static Lint, span: Option<S>, decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), )

Emit a lint at the appropriate level, with an optional associated span.

Source

fn get_lint_level(&self, lint: &'static Lint) -> Level

This returns the lint level for the given lint at the current location.

Provided Methods§

Source

fn emit_span_lint<S: Into<MultiSpan>>( &self, lint: &'static Lint, span: S, decorator: impl for<'a> LintDiagnostic<'a, ()>, )

Emit a lint at span from a lint struct (some type that implements LintDiagnostic, typically generated by #[derive(LintDiagnostic)]).

Source

fn span_lint<S: Into<MultiSpan>>( &self, lint: &'static Lint, span: S, decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), )

Emit a lint at the appropriate level, with an associated span.

Source

fn emit_lint( &self, lint: &'static Lint, decorator: impl for<'a> LintDiagnostic<'a, ()>, )

Emit a lint from a lint struct (some type that implements LintDiagnostic, typically generated by #[derive(LintDiagnostic)]).

Source

fn lint( &self, lint: &'static Lint, decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), )

Emit a lint at the appropriate level, with no associated span.

Source

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 LintExpectationIds retrieved from the current lint pass. Buffered or manually created ids can cause ICEs.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§