Skip to content

Commit 49d2825

Browse files
committed
Place optimize for size and minsize rustc invocation options behind a nightly
compiler check to prevent their inclusion in the stable / beta compilers.
1 parent 8a8493a commit 49d2825

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/librustc/session/config.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -1127,17 +1127,18 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
11271127
}
11281128
OptLevel::Default
11291129
} else {
1130-
match cg.opt_level.as_ref().map(String::as_ref) {
1131-
None => OptLevel::No,
1132-
Some("0") => OptLevel::No,
1133-
Some("1") => OptLevel::Less,
1134-
Some("2") => OptLevel::Default,
1135-
Some("3") => OptLevel::Aggressive,
1136-
Some("s") => OptLevel::Size,
1137-
Some("z") => OptLevel::SizeMin,
1138-
Some(arg) => {
1130+
match (cg.opt_level.as_ref().map(String::as_ref),
1131+
nightly_options::is_nightly_build()) {
1132+
(None, _) => OptLevel::No,
1133+
(Some("0"), _) => OptLevel::No,
1134+
(Some("1"), _) => OptLevel::Less,
1135+
(Some("2"), _) => OptLevel::Default,
1136+
(Some("3"), _) => OptLevel::Aggressive,
1137+
(Some("s"), true) => OptLevel::Size,
1138+
(Some("z"), true) => OptLevel::SizeMin,
1139+
(Some(arg), _) => {
11391140
early_error(error_format, &format!("optimization level needs to be \
1140-
between 0-3, s, or z (instead was `{}`)",
1141+
between 0-3 (instead was `{}`)",
11411142
arg));
11421143
}
11431144
}
@@ -1308,7 +1309,7 @@ pub mod nightly_options {
13081309
is_nightly_build() && matches.opt_strs("Z").iter().any(|x| *x == "unstable-options")
13091310
}
13101311

1311-
fn is_nightly_build() -> bool {
1312+
pub fn is_nightly_build() -> bool {
13121313
match get_unstable_features_setting() {
13131314
UnstableFeatures::Allow | UnstableFeatures::Cheat => true,
13141315
_ => false,

0 commit comments

Comments
 (0)