Skip to content

Commit 3f47cd1

Browse files
committed
Auto merge of #9036 - xFrednet:0000-force-warn-in-driver, r=dswij
Check for `--force-warn` in Clippy's driver run condition Just a thing I've noticed while tinkering on the driver. Currently, the driver only checks for `--cap-lints=allow` to determine if Clippy should run on the code, but ignores possible `--force-warn` arguments --- changelog: Others: Allowing all lints and only `--force-warn`ing some will now work with Clippy's driver
2 parents f718984 + 4182803 commit 3f47cd1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/driver.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ fn test_arg_value() {
6060
assert_eq!(arg_value(args, "--bar", |p| p == "foo"), None);
6161
assert_eq!(arg_value(args, "--foobar", |p| p == "foo"), None);
6262
assert_eq!(arg_value(args, "--foobar", |p| p == "123"), Some("123"));
63+
assert_eq!(arg_value(args, "--foobar", |p| p.contains("12")), Some("123"));
6364
assert_eq!(arg_value(args, "--foo", |_| true), None);
6465
}
6566

@@ -334,15 +335,13 @@ pub fn main() {
334335
// - IF Clippy is run on the main crate, not on deps (`!cap_lints_allow`) THEN
335336
// - IF `--no-deps` is not set (`!no_deps`) OR
336337
// - IF `--no-deps` is set and Clippy is run on the specified primary package
337-
let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some();
338+
let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some()
339+
&& arg_value(&orig_args, "--force-warn", |val| val.contains("clippy::")).is_none();
338340
let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok();
339341

340342
let clippy_enabled = !cap_lints_allow && (!no_deps || in_primary_package);
341343
if clippy_enabled {
342344
args.extend(clippy_args);
343-
}
344-
345-
if clippy_enabled {
346345
rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var }).run()
347346
} else {
348347
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run()

0 commit comments

Comments
 (0)