@@ -18,7 +18,7 @@ use rustc_serialize::json;
1818
1919use crate :: parse:: CrateConfig ;
2020use 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 } ;
2222use rustc_span:: source_map:: { FileName , FilePathMapping } ;
2323use rustc_span:: symbol:: { sym, Symbol } ;
2424use 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