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§
source§impl Driver
 
impl Driver
sourcepub fn with_cfg(self, cfg: impl Into<String>) -> Self
 
pub fn with_cfg(self, cfg: impl Into<String>) -> Self
Add --cfg={cfg} flag to the compiler invocation.
This allows for the following pattern:
#[cfg_attr(nag, allow(custom_lint))]
fn func() {
    // ...
}sourcepub fn with_callback<F>(self, callback: F) -> Selfwhere
    F: Fn(&Session, &mut LintStore) + Send + Sync + 'static,
 
pub fn with_callback<F>(self, callback: F) -> Selfwhere
    F: Fn(&Session, &mut LintStore) + Send + Sync + 'static,
Add a single callback for registering lints.
sourcepub fn with_callbacks<F, I>(self, callbacks: I) -> Selfwhere
    F: Fn(&Session, &mut LintStore) + Send + Sync + 'static,
    I: IntoIterator<Item = F>,
 
pub fn with_callbacks<F, I>(self, callbacks: I) -> Selfwhere
    F: Fn(&Session, &mut LintStore) + Send + Sync + 'static,
    I: IntoIterator<Item = F>,
Add multiple callbacks for registering lints.
sourcepub fn run(self) -> ExitCode
 
pub fn run(self) -> ExitCode
Run the driver with args from the std::env::args. This is probably what you want.
sourcepub fn run_with_args(self, args: impl IntoIterator<Item = String>) -> ExitCode
 
pub fn run_with_args(self, args: impl IntoIterator<Item = String>) -> ExitCode
Run the driver with custom args.
Note: argv[0], i.e. the executable name (rustc), should be passed into this function.
Trait Implementations§
source§impl Callbacks for Driver
 
impl Callbacks for Driver
This implementation will clear the callbacks list stored inside of Driver.
You probably should use Driver::run() or Driver::run_with_args() instead.
source§fn after_parsing<'tcx>(
    &mut self,
    _compiler: &Compiler,
    _queries: &'tcx Queries<'tcx>
) -> Compilation
 
fn after_parsing<'tcx>(
    &mut self,
    _compiler: &Compiler,
    _queries: &'tcx Queries<'tcx>
) -> Compilation
Called after parsing. Return value instructs the compiler whether to
continue the compilation afterwards (defaults to 
Compilation::Continue)source§fn after_expansion<'tcx>(
    &mut self,
    _compiler: &Compiler,
    _queries: &'tcx Queries<'tcx>
) -> Compilation
 
fn after_expansion<'tcx>(
    &mut self,
    _compiler: &Compiler,
    _queries: &'tcx Queries<'tcx>
) -> Compilation
Called after expansion. Return value instructs the compiler whether to
continue the compilation afterwards (defaults to 
Compilation::Continue)source§fn after_analysis<'tcx>(
    &mut self,
    _compiler: &Compiler,
    _queries: &'tcx Queries<'tcx>
) -> Compilation
 
fn after_analysis<'tcx>(
    &mut self,
    _compiler: &Compiler,
    _queries: &'tcx Queries<'tcx>
) -> Compilation
Called after analysis. Return value instructs the compiler whether to
continue the compilation afterwards (defaults to 
Compilation::Continue)