]> git.lizzy.rs Git - rust.git/commitdiff
Apply suggestion regarding clippy_enabled bool
authorEduardo Broto <ebroto@tutanota.com>
Wed, 25 Nov 2020 14:02:47 +0000 (15:02 +0100)
committerEduardo Broto <ebroto@tutanota.com>
Fri, 27 Nov 2020 16:41:50 +0000 (17:41 +0100)
src/driver.rs

index bbe9ce739368e3fd2971db453a1e299f9bab1ac8..03381106de1a645b7a9dc93f0284e9d011ee4882 100644 (file)
@@ -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()
     }))
 }