add EDITIONS_NAME_LIST, make edition tracked, enforce that only stable editions are allowed to be used on non-nightly builds

This commit is contained in:
Kurtis Nusbaum 2018-04-19 21:03:21 -07:00
parent 51f51109ce
commit 320fdaa942
3 changed files with 30 additions and 11 deletions

View file

@ -24,7 +24,8 @@ pub enum Edition {
// when adding new editions, be sure to update:
//
// - the list in the `parse_edition` static in librustc::session::config
// - Update the `ALL_EDITIONS` const
// - Update the EDITION_NAME_LIST const
// - add a `rust_####()` function to the session
// - update the enum in Cargo's sources as well
}
@ -32,6 +33,8 @@ pub enum Edition {
// must be in order from oldest to newest
pub const ALL_EDITIONS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018];
pub const EDITION_NAME_LIST: &'static str = "2015|2018";
pub const DEFAULT_EDITION: Edition = Edition::Edition2015;
impl fmt::Display for Edition {
@ -58,6 +61,13 @@ impl Edition {
Edition::Edition2018 => "rust_2018_preview",
}
}
pub fn is_stable(&self) -> bool {
match *self {
Edition::Edition2015 => true,
Edition::Edition2018 => false,
}
}
}
impl FromStr for Edition {