Skip to content

Commit 4daa263

Browse files
committed
Always print lints from plugins, if they're available
Currently you can get a list of lints and lint groups by running `rustc -Whelp`. This prints an additional line at the end: ``` Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename. ``` Clippy is such a "compiler plugin", that provides additional lints. Running `clippy-driver -Whelp` (`rustc` wrapper) still only prints the rustc lints with the above message at the end. But when running `clippy-driver -Whelp main.rs`, where `main.rs` is any rust file, it also prints Clippy lints. I don't think this is a good approach from a UX perspective: Why is a random file necessary to print a help message? This commit changes this behavior: Whenever a compiler callback registers lints, it is assumed that these lints come from a plugin and are printed without having to specify a Rust source file.
1 parent be1e502 commit 4daa263

File tree

1 file changed

+9
-2
lines changed
  • compiler/rustc_driver/src

1 file changed

+9
-2
lines changed

compiler/rustc_driver/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,18 @@ fn run_compiler(
248248
interface::run_compiler(config, |compiler| {
249249
let sopts = &compiler.session().opts;
250250
if sopts.describe_lints {
251-
let lint_store = rustc_lint::new_lint_store(
251+
let mut lint_store = rustc_lint::new_lint_store(
252252
sopts.debugging_opts.no_interleave_lints,
253253
compiler.session().unstable_options(),
254254
);
255-
describe_lints(compiler.session(), &lint_store, false);
255+
let registered_lints =
256+
if let Some(register_lints) = compiler.register_lints() {
257+
register_lints(compiler.session(), &mut lint_store);
258+
true
259+
} else {
260+
false
261+
};
262+
describe_lints(compiler.session(), &lint_store, registered_lints);
256263
return;
257264
}
258265
let should_stop = RustcDefaultCalls::print_crate_info(

0 commit comments

Comments
 (0)