summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornel <kornel@geekhood.net>2021-04-10 11:46:36 +0100
committerKornel <kornel@geekhood.net>2021-04-10 13:35:35 +0100
commit40af086ee448e4a5dad03a66dd3b7e39f7451ac7 (patch)
tree191d33016ce0d17054c48d7c7374b51ee26e3371
parent481598b26db6144c580dc113f4d78b4151b5a1bc (diff)
downloadrust-40af086ee448e4a5dad03a66dd3b7e39f7451ac7.tar.gz
Don't tell users to use a nightly flag on the stable channel
Hint upgrading to a newer Rust version instead
-rw-r--r--compiler/rustc_session/src/config.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index 75bd8880b34..b6b349e4a80 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -18,7 +18,7 @@ use rustc_serialize::json;
use crate::parse::CrateConfig;
use rustc_feature::UnstableFeatures;
-use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST};
+use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
use rustc_span::source_map::{FileName, FilePathMapping};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::SourceFileHashAlgorithm;
@@ -1320,13 +1320,16 @@ pub fn parse_crate_edition(matches: &getopts::Matches) -> Edition {
};
if !edition.is_stable() && !nightly_options::is_unstable_enabled(matches) {
- early_error(
- ErrorOutputType::default(),
- &format!(
- "edition {} is unstable and only available with -Z unstable-options.",
- edition,
- ),
- )
+ let is_nightly = nightly_options::match_is_nightly_build(matches);
+ let msg = if !is_nightly {
+ format!(
+ "the crate requires edition {}, but the latest edition supported by this Rust version is {}",
+ edition, LATEST_STABLE_EDITION
+ )
+ } else {
+ format!("edition {} is unstable and only available with -Z unstable-options", edition)
+ };
+ early_error(ErrorOutputType::default(), &msg)
}
edition