diff options
| author | Kurtis Nusbaum <kurtis@uber.com> | 2018-04-19 21:03:21 -0700 |
|---|---|---|
| committer | Kurtis Nusbaum <kurtis@uber.com> | 2018-04-19 21:03:21 -0700 |
| commit | 320fdaa9423ba2ae35c283707c1501a03dd511cf (patch) | |
| tree | 04b22eba29a5108a371b1b476278bd6412db7f82 /src/libsyntax | |
| parent | 51f51109ce8c3070ab186624c241216620942360 (diff) | |
| download | rust-320fdaa9423ba2ae35c283707c1501a03dd511cf.tar.gz rust-320fdaa9423ba2ae35c283707c1501a03dd511cf.zip | |
add EDITIONS_NAME_LIST, make edition tracked, enforce that only stable editions are allowed to be used on non-nightly builds
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/edition.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libsyntax/edition.rs b/src/libsyntax/edition.rs index 4c1d52d7b07..3fc1c279f5a 100644 --- a/src/libsyntax/edition.rs +++ b/src/libsyntax/edition.rs @@ -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 { |
