summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-04-21 05:28:21 +0000
committerbors <bors@rust-lang.org>2018-04-21 05:28:21 +0000
commit9af69fe2320bde44b96d85d316a95083fb65c4b8 (patch)
tree8e0d0b3ca666e17dcca6124e77a8e39a211c24d9 /src/libsyntax
parentb78853b6fd9597dc42ccf044fed805851d0a6f91 (diff)
parentc8c9bf97e3ed2eab3ed60a3412574e7c5b548eab (diff)
downloadrust-9af69fe2320bde44b96d85d316a95083fb65c4b8.tar.gz
rust-9af69fe2320bde44b96d85d316a95083fb65c4b8.zip
Auto merge of #50080 - klnusbaum:edition_49591, r=Manishearth
add --edition option

This adds an official `edition` flag to the rust compiler
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/edition.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libsyntax/edition.rs b/src/libsyntax/edition.rs
index e579fc74b42..3fc1c279f5a 100644
--- a/src/libsyntax/edition.rs
+++ b/src/libsyntax/edition.rs
@@ -24,20 +24,19 @@ 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
-    //
-    // When -Zedition becomes --edition, there will
-    // also be a check for the edition being nightly-only
-    // somewhere. That will need to be updated
-    // whenever we're stabilizing/introducing a new edition
-    // as well as changing the default Cargo template.
 }
 
 // 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 {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let s = match *self {
@@ -62,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 {