diff options
| author | Eduardo Broto <ebroto@tutanota.com> | 2020-11-25 15:02:47 +0100 |
|---|---|---|
| committer | Eduardo Broto <ebroto@tutanota.com> | 2020-11-27 17:41:50 +0100 |
| commit | 7eda421e9629a717d31ec03d12b4befd03f5fb50 (patch) | |
| tree | 2230efc0bf43047ef7cddac3749303144c9ad6ab | |
| parent | 192ccfb4efc0a38378f4564b26e6033dec432bdb (diff) | |
| download | rust-7eda421e9629a717d31ec03d12b4befd03f5fb50.tar.gz rust-7eda421e9629a717d31ec03d12b4befd03f5fb50.zip | |
Apply suggestion regarding clippy_enabled bool
| -rw-r--r-- | src/driver.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/driver.rs b/src/driver.rs index bbe9ce73936..03381106de1 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -182,6 +182,7 @@ fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<Pat }) } +#[allow(clippy::too_many_lines)] pub fn main() { rustc_driver::init_rustc_env_logger(); SyncLazy::force(&ICE_HOOK); @@ -294,17 +295,20 @@ pub fn main() { // this check ensures that dependencies are built but not linted and the final // crate is linted but not built - let clippy_disabled = env::var("CLIPPY_TESTS").map_or(false, |val| val != "true") - || arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some() - || no_deps && env::var("CARGO_PRIMARY_PACKAGE").is_err(); + let clippy_tests_set = env::var("CLIPPY_TESTS").map_or(false, |val| val == "true"); + let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some(); + let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok(); - if !clippy_disabled { + let clippy_enabled = clippy_tests_set || (!cap_lints_allow && (!no_deps || in_primary_package)); + if clippy_enabled { args.extend(clippy_args); } + let mut clippy = ClippyCallbacks; let mut default = DefaultCallbacks; let callbacks: &mut (dyn rustc_driver::Callbacks + Send) = - if clippy_disabled { &mut default } else { &mut clippy }; + if clippy_enabled { &mut clippy } else { &mut default }; + rustc_driver::RunCompiler::new(&args, callbacks).run() })) } |
