Skip to main content

Violation

Trait Violation 

Source
pub trait Violation: ViolationMetadata + Sized {
    const FIX_AVAILABILITY: FixAvailability = FixAvailability::None;

    // Required methods
    fn message(&self) -> String;
    fn message_formats() -> &'static [&'static str];

    // Provided methods
    fn fix_title(&self) -> Option<String> { ... }
    fn into_diagnostic(self, range: TextRange, file: &SourceFile) -> Diagnostic { ... }
}

Provided Associated Constants§

Source

const FIX_AVAILABILITY: FixAvailability = FixAvailability::None

None in the case a fix is never available or otherwise Some FixAvailability describing the available fix.

Required Methods§

Source

fn message(&self) -> String

The message used to describe the violation.

Source

fn message_formats() -> &'static [&'static str]

Returns the format strings used by message.

Provided Methods§

Source

fn fix_title(&self) -> Option<String>

Returns the title for the fix. The message is also shown as an advice as part of the diagnostics.

Required for rules that have fixes.

Source

fn into_diagnostic(self, range: TextRange, file: &SourceFile) -> Diagnostic

Convert the violation into a Diagnostic.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Violation for IOError

E902

Source§

impl<V: AlwaysFixableViolation> Violation for V

A blanket implementation.

Source§

const FIX_AVAILABILITY: FixAvailability = FixAvailability::Always