Skip to main content

Lint

Trait Lint 

Source
pub trait Lint {
    // Required methods
    fn new(ctx: &LintCtx) -> Self
       where Self: Sized;
    fn enter_workspace(&mut self, content: &Lintable<DocumentMut>);
    fn enter_crate(&mut self, content: &Lintable<DocumentMut>);
    fn visit_file(&mut self, content: &mut Lintable<String>);
    fn exit_crate(&mut self, content: &mut Lintable<DocumentMut>);
    fn exit_workspace(&mut self, content: &mut Lintable<DocumentMut>);

    // Provided method
    fn visit_nonrust_file(
        &mut self,
        extension: &str,
        content: &mut Lintable<String>,
    ) { ... }
}
Expand description

A trait representing a single lint check.

Required Methods§

Source

fn new(ctx: &LintCtx) -> Self
where Self: Sized,

Create a new instance of this lint for a workspace.

Source

fn enter_workspace(&mut self, content: &Lintable<DocumentMut>)

Begin processing a workspace, given the parsed Cargo.toml of the workspace root.

Source

fn enter_crate(&mut self, content: &Lintable<DocumentMut>)

Begin processing a crate, given the parsed Cargo.toml of the crate root.

Source

fn visit_file(&mut self, content: &mut Lintable<String>)

Process a Rust source file in the current crate.

Source

fn exit_crate(&mut self, content: &mut Lintable<DocumentMut>)

Finish processing a crate, given the parsed Cargo.toml of the crate root.

Source

fn exit_workspace(&mut self, content: &mut Lintable<DocumentMut>)

Finish processing a workspace, given the parsed Cargo.toml of the workspace root.

Provided Methods§

Source

fn visit_nonrust_file( &mut self, extension: &str, content: &mut Lintable<String>, )

Process a non-Rust file in the current crate or workspace.

For files within the directory of a crate this is called during crate processing. For files outside of any crate this is called during workspace processing after all crates have been processed.

Implementors§