Skip to content

Commit 3d757ea

Browse files
committed
Apply suggestion regarding clippy_enabled bool
1 parent d675ea7 commit 3d757ea

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/driver.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<Pat
292292
})
293293
}
294294

295+
#[allow(clippy::too_many_lines)]
295296
pub fn main() {
296297
rustc_driver::init_rustc_env_logger();
297298
SyncLazy::force(&ICE_HOOK);
@@ -415,17 +416,20 @@ pub fn main() {
415416

416417
// this check ensures that dependencies are built but not linted and the final
417418
// crate is linted but not built
418-
let clippy_disabled = env::var("CLIPPY_TESTS").map_or(false, |val| val != "true")
419-
|| arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some()
420-
|| no_deps && env::var("CARGO_PRIMARY_PACKAGE").is_err();
419+
let clippy_tests_set = env::var("CLIPPY_TESTS").map_or(false, |val| val == "true");
420+
let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some();
421+
let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok();
421422

422-
if !clippy_disabled {
423+
let clippy_enabled = clippy_tests_set || (!cap_lints_allow && (!no_deps || in_primary_package));
424+
if clippy_enabled {
423425
args.extend(clippy_args);
424426
}
427+
425428
let mut clippy = ClippyCallbacks;
426429
let mut default = DefaultCallbacks;
427430
let callbacks: &mut (dyn rustc_driver::Callbacks + Send) =
428-
if clippy_disabled { &mut default } else { &mut clippy };
431+
if clippy_enabled { &mut clippy } else { &mut default };
432+
429433
rustc_driver::RunCompiler::new(&args, callbacks).run()
430434
}))
431435
}

0 commit comments

Comments
 (0)