Skip to content

Commit dbed65a

Browse files
committed
Simplify checking of crt_static_feature()
1 parent 84349cc commit dbed65a

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

src/librustc_session/session.rs

+10-26
Original file line numberDiff line numberDiff line change
@@ -556,33 +556,17 @@ impl Session {
556556
let found_negative = requested_features.clone().any(|r| r == "-crt-static");
557557
let found_positive = requested_features.clone().any(|r| r == "+crt-static");
558558

559-
if self.target.target.options.crt_static_default {
560-
// `proc-macro` always required to be compiled to dylibs.
561-
// We don't use a static crt unless the `+crt-static` feature was passed.
562-
if !self.target.target.options.crt_static_allows_dylibs {
563-
match crate_type {
564-
Some(config::CrateType::ProcMacro) => found_positive,
565-
Some(_) => !found_negative,
566-
None => {
567-
// FIXME: When crate_type is not available,
568-
// we use compiler options to determine the crate_type.
569-
// We can't check `#![crate_type = "proc-macro"]` here.
570-
if self.opts.crate_types.contains(&config::CrateType::ProcMacro) {
571-
found_positive
572-
} else {
573-
!found_negative
574-
}
575-
}
576-
}
577-
} else {
578-
// If the target we're compiling for requests a static crt by default,
579-
// then see if the `-crt-static` feature was passed to disable that.
580-
!found_negative
581-
}
582-
} else {
583-
// If the target we're compiling for don't have a static crt by default then see if the
584-
// `+crt-static` feature was passed.
559+
if found_positive || found_negative {
585560
found_positive
561+
} else if crate_type == Some(config::CrateType::ProcMacro)
562+
|| self.opts.crate_types.contains(&config::CrateType::ProcMacro)
563+
{
564+
// FIXME: When crate_type is not available,
565+
// we use compiler options to determine the crate_type.
566+
// We can't check `#![crate_type = "proc-macro"]` here.
567+
false
568+
} else {
569+
self.target.target.options.crt_static_default
586570
}
587571
}
588572

0 commit comments

Comments
 (0)