Check for --force-warn in Clippy's driver run condition

This commit is contained in:
xFrednet 2022-06-23 09:44:53 +02:00
parent b3c94c0828
commit 4182803b86
No known key found for this signature in database
GPG key ID: F5C59D0E669E5302

View file

@ -60,6 +60,7 @@ fn test_arg_value() {
assert_eq!(arg_value(args, "--bar", |p| p == "foo"), None);
assert_eq!(arg_value(args, "--foobar", |p| p == "foo"), None);
assert_eq!(arg_value(args, "--foobar", |p| p == "123"), Some("123"));
assert_eq!(arg_value(args, "--foobar", |p| p.contains("12")), Some("123"));
assert_eq!(arg_value(args, "--foo", |_| true), None);
}
@ -334,15 +335,13 @@ pub fn main() {
// - IF Clippy is run on the main crate, not on deps (`!cap_lints_allow`) THEN
// - IF `--no-deps` is not set (`!no_deps`) OR
// - IF `--no-deps` is set and Clippy is run on the specified primary package
let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some();
let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some()
&& arg_value(&orig_args, "--force-warn", |val| val.contains("clippy::")).is_none();
let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok();
let clippy_enabled = !cap_lints_allow && (!no_deps || in_primary_package);
if clippy_enabled {
args.extend(clippy_args);
}
if clippy_enabled {
rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var }).run()
} else {
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run()