]> git.lizzy.rs Git - rust.git/commitdiff
Use a let-chain in _session::output (nfc)
authorJubilee Young <workingjubilee@gmail.com>
Fri, 25 Mar 2022 05:31:46 +0000 (22:31 -0700)
committerJubilee Young <workingjubilee@gmail.com>
Fri, 25 Mar 2022 05:38:32 +0000 (22:38 -0700)
compiler/rustc_session/src/lib.rs
compiler/rustc_session/src/output.rs

index 2db217d97160a56ad9441310e25a0d864667b400..bd4e37f1ab794847b699b47bba63429fdc3d4254 100644 (file)
@@ -1,5 +1,6 @@
 #![feature(crate_visibility_modifier)]
 #![feature(derive_default_enum)]
+#![feature(let_chains)]
 #![feature(let_else)]
 #![feature(min_specialization)]
 #![feature(once_cell)]
index c6648f9d740360b22ffde1a23350b92669d4613b..e5e6579d75b10604d584089f2a2f970c34eb9a78 100644 (file)
@@ -183,24 +183,18 @@ pub fn default_output_for_target(sess: &Session) -> CrateType {
 
 /// Checks if target supports crate_type as output
 pub fn invalid_output_for_target(sess: &Session, crate_type: CrateType) -> bool {
-    match crate_type {
-        CrateType::Cdylib | CrateType::Dylib | CrateType::ProcMacro => {
-            if !sess.target.dynamic_linking {
-                return true;
-            }
-            if sess.crt_static(Some(crate_type)) && !sess.target.crt_static_allows_dylibs {
-                return true;
-            }
+    if let CrateType::Cdylib | CrateType::Dylib | CrateType::ProcMacro = crate_type {
+        if !sess.target.dynamic_linking {
+            return true;
         }
-        _ => {}
-    }
-    if sess.target.only_cdylib {
-        match crate_type {
-            CrateType::ProcMacro | CrateType::Dylib => return true,
-            _ => {}
+        if sess.crt_static(Some(crate_type)) && !sess.target.crt_static_allows_dylibs {
+            return true;
         }
     }
-    if !sess.target.executables && crate_type == CrateType::Executable {
+    if let CrateType::ProcMacro | CrateType::Dylib = crate_type && sess.target.only_cdylib {
+        return true;
+    }
+    if let CrateType::Executable = crate_type && !sess.target.executables {
         return true;
     }