Skip to content

Commit 7eda421

Browse files
committed
Apply suggestion regarding clippy_enabled bool
1 parent 192ccfb commit 7eda421

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
@@ -182,6 +182,7 @@ fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<Pat
182182
})
183183
}
184184

185+
#[allow(clippy::too_many_lines)]
185186
pub fn main() {
186187
rustc_driver::init_rustc_env_logger();
187188
SyncLazy::force(&ICE_HOOK);
@@ -294,17 +295,20 @@ pub fn main() {
294295

295296
// this check ensures that dependencies are built but not linted and the final
296297
// crate is linted but not built
297-
let clippy_disabled = env::var("CLIPPY_TESTS").map_or(false, |val| val != "true")
298-
|| arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some()
299-
|| no_deps && env::var("CARGO_PRIMARY_PACKAGE").is_err();
298+
let clippy_tests_set = env::var("CLIPPY_TESTS").map_or(false, |val| val == "true");
299+
let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some();
300+
let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok();
300301

301-
if !clippy_disabled {
302+
let clippy_enabled = clippy_tests_set || (!cap_lints_allow && (!no_deps || in_primary_package));
303+
if clippy_enabled {
302304
args.extend(clippy_args);
303305
}
306+
304307
let mut clippy = ClippyCallbacks;
305308
let mut default = DefaultCallbacks;
306309
let callbacks: &mut (dyn rustc_driver::Callbacks + Send) =
307-
if clippy_disabled { &mut default } else { &mut clippy };
310+
if clippy_enabled { &mut clippy } else { &mut default };
311+
308312
rustc_driver::RunCompiler::new(&args, callbacks).run()
309313
}))
310314
}

0 commit comments

Comments
 (0)