Skip to content

Commit fd2448b

Browse files
Use a let-chain in _session::output (nfc)
1 parent d3ca9ba commit fd2448b

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

compiler/rustc_session/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(crate_visibility_modifier)]
22
#![feature(derive_default_enum)]
3+
#![feature(let_chains)]
34
#![feature(let_else)]
45
#![feature(min_specialization)]
56
#![feature(once_cell)]

compiler/rustc_session/src/output.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,18 @@ pub fn default_output_for_target(sess: &Session) -> CrateType {
183183

184184
/// Checks if target supports crate_type as output
185185
pub fn invalid_output_for_target(sess: &Session, crate_type: CrateType) -> bool {
186-
match crate_type {
187-
CrateType::Cdylib | CrateType::Dylib | CrateType::ProcMacro => {
188-
if !sess.target.dynamic_linking {
189-
return true;
190-
}
191-
if sess.crt_static(Some(crate_type)) && !sess.target.crt_static_allows_dylibs {
192-
return true;
193-
}
186+
if let CrateType::Cdylib | CrateType::Dylib | CrateType::ProcMacro = crate_type {
187+
if !sess.target.dynamic_linking {
188+
return true;
194189
}
195-
_ => {}
196-
}
197-
if sess.target.only_cdylib {
198-
match crate_type {
199-
CrateType::ProcMacro | CrateType::Dylib => return true,
200-
_ => {}
190+
if sess.crt_static(Some(crate_type)) && !sess.target.crt_static_allows_dylibs {
191+
return true;
201192
}
202193
}
203-
if !sess.target.executables && crate_type == CrateType::Executable {
194+
if let CrateType::ProcMacro | CrateType::Dylib = crate_type && sess.target.only_cdylib {
195+
return true;
196+
}
197+
if let CrateType::Executable = crate_type && !sess.target.executables {
204198
return true;
205199
}
206200

0 commit comments

Comments
 (0)