Skip to content

Commit 4029d4d

Browse files
committed
Auto merge of #84055 - kornelski:z-edition, r=petrochenkov
Don't tell users to use a nightly flag on the stable channel When a crate requires a newer edition, currently rustc tells users to use `-Z unstable-options`. This is not ideal, because: * This flag doesn't work on the stable channel, so solution to one error only causes another error, which is frustrating. * Directs users towards the nightly channel, which is not necessarily the correct solution. Once the next edition is released, this message will be mostly seen by users of out-of-date stable Rust versions who merely need to update their Rust to the latest stable.
2 parents 18c524f + 40af086 commit 4029d4d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

compiler/rustc_session/src/config.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_serialize::json;
1818

1919
use crate::parse::CrateConfig;
2020
use rustc_feature::UnstableFeatures;
21-
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST};
21+
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
2222
use rustc_span::source_map::{FileName, FilePathMapping};
2323
use rustc_span::symbol::{sym, Symbol};
2424
use rustc_span::SourceFileHashAlgorithm;
@@ -1320,13 +1320,16 @@ pub fn parse_crate_edition(matches: &getopts::Matches) -> Edition {
13201320
};
13211321

13221322
if !edition.is_stable() && !nightly_options::is_unstable_enabled(matches) {
1323-
early_error(
1324-
ErrorOutputType::default(),
1325-
&format!(
1326-
"edition {} is unstable and only available with -Z unstable-options.",
1327-
edition,
1328-
),
1329-
)
1323+
let is_nightly = nightly_options::match_is_nightly_build(matches);
1324+
let msg = if !is_nightly {
1325+
format!(
1326+
"the crate requires edition {}, but the latest edition supported by this Rust version is {}",
1327+
edition, LATEST_STABLE_EDITION
1328+
)
1329+
} else {
1330+
format!("edition {} is unstable and only available with -Z unstable-options", edition)
1331+
};
1332+
early_error(ErrorOutputType::default(), &msg)
13301333
}
13311334

13321335
edition

0 commit comments

Comments
 (0)