Function rustc_tools::with_lints
source · pub fn with_lints<F: Fn(&mut LintStore) + Send + Sync + 'static>(
args: &[String],
tracked_files: Vec<String>,
callback: F,
) -> Result<(), FatalError>Expand description
If you want to create a linter, this the function you want to use.
argsis what is provided to the compiler.tracked_filesis the files which will trigger a re-compilation if they are modified.callbackis called when everything is setup. This is where you will register your lints before they are run by rustc directly. It provides a mutable reference to theLintStoretype.
Take a look at the examples/lint.rs file if you want an example on how to create lints.
VERY IMPORTANT TO NOTE: if you want to run this code on a crate with dependencies, you’ll
need to pass the according options so that rustc knows where to look for them. otherwise it
will simply fail to compile and the callback won’t be called. A good example of the list
of the expected arguments can be seen when you run cargo build -v.
Take a look at cargo_integration and at
rustc-tools-example to see how to
write a cargo integration.