Struct marker_api::Lint

source ·
#[repr(C)]
pub struct Lint { pub name: &'static str, pub default_level: Level, pub explanation: &'static str, pub report_in_macro: MacroReport, pub fqn: &'static str, pub _unstable_i_accept_the_risk_of_instability: (), }
Expand description

This struct defines a lint.

It should never be constructed directly, the declare_lint macro should be used instead, like this:

marker_api::declare_lint!{
    /// # What it does
    /// Here you can describe what your lint does.
    ///
    /// # Example
    /// ```
    /// <bad example>
    /// ```
    ///
    /// Use instead
    /// ```
    /// <bad example>
    /// ```
    ITEM_WITH_TEST_NAME,
    Warn,
}

The fields of this struct are public, to allow the instantiation in constant context. Marker reserves the right to add new fields, as long the lint can still be constructed using the declare_lint macro.

Fields§

§name: &'static str

The string identifier of this lint.

Identifiers use underscores, to connect multiple words, e.g., “unused_imports”. Lint names in console arguments use dashes instead of underscores. These are automatically converted to underscores internally.

Identifiers in Marker are split into three parts:

  1. The marker prefix, specifying that the lint comes from Marker
  2. The lint crate name, as an infix
  3. The name of the lint, as the postfix

See https://rustc-dev-guide.rust-lang.org/diagnostics.html#lint-naming for naming guidelines.

§default_level: Level

Default level for the lint.

See https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-levels for guidelines on choosing a default level.

§explanation: &'static str

Description of the lint or the issue it detects.

e.g., “imports that are never used”

§report_in_macro: MacroReport

The level of macro reporting.

See MacroReport for the possible levels.

§fqn: &'static str

Fully qualiefied name of the static variable that defines the lint. It includes the module and the name of the variable.

§_unstable_i_accept_the_risk_of_instability: ()

This struct should always be instantiated using the declare_lint macro. This value is simply here, to force any construction to acknowledge the instability of manual construction.

Trait Implementations§

source§

impl Debug for Lint

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Lint

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Lint

source§

fn eq(&self, other: &Lint) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Lint

source§

impl StructuralEq for Lint

source§

impl StructuralPartialEq for Lint

Auto Trait Implementations§

§

impl RefUnwindSafe for Lint

§

impl Send for Lint

§

impl Sync for Lint

§

impl Unpin for Lint

§

impl UnwindSafe for Lint

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.