mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Check for --force-warn
in Clippy's driver run condition
This commit is contained in:
parent
b3c94c0828
commit
4182803b86
1 changed files with 3 additions and 4 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue