Struct nag_driver::Driver

source ·
pub struct Driver { /* private fields */ }
Expand description

The entry point for a custom linter.

Use it like this:

fn main() -> ExitCode {
    Driver::new()
        .with_cfg("nag")
        .with_callbacks([
            lints::register,
            external_lints::register,
        ])
        .run()
}

Implementations§

Create a new Driver.

Add --cfg={cfg} flag to the compiler invocation.

This allows for the following pattern:

#[cfg_attr(nag, allow(custom_lint))]
fn func() {
    // ...
}

Add a single callback for registering lints.

Add multiple callbacks for registering lints.

Run the driver with args from the std::env::args. This is probably what you want.

Run the driver with custom args.

Note: argv[0], i.e. the executable name (rustc), should be passed into this function.

Trait Implementations§

This implementation will clear the callbacks list stored inside of Driver.

You probably should use Driver::run() or Driver::run_with_args() instead.

Called before creating the compiler instance
Called after parsing. Return value instructs the compiler whether to continue the compilation afterwards (defaults to Compilation::Continue)
Called after expansion. Return value instructs the compiler whether to continue the compilation afterwards (defaults to Compilation::Continue)
Called after analysis. Return value instructs the compiler whether to continue the compilation afterwards (defaults to Compilation::Continue)
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.