@@ -18,7 +18,7 @@ use rustc_serialize::json;
18
18
19
19
use crate :: parse:: CrateConfig ;
20
20
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 } ;
22
22
use rustc_span:: source_map:: { FileName , FilePathMapping } ;
23
23
use rustc_span:: symbol:: { sym, Symbol } ;
24
24
use rustc_span:: SourceFileHashAlgorithm ;
@@ -1320,13 +1320,16 @@ pub fn parse_crate_edition(matches: &getopts::Matches) -> Edition {
1320
1320
} ;
1321
1321
1322
1322
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)
1330
1333
}
1331
1334
1332
1335
edition
0 commit comments