-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add --edition option #50080
add --edition option #50080
Changes from all commits
51f5110
320fdaa
c1d8aa8
c8c9bf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would really like to avoid introducing this. Would be great if we could derive it some way from something that already exists so we have one less thing to change when adding an edition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using custom derives within libsyntax itself is annoying and tricky. We'd need to do a snapshot, I think. |
||
|
||
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 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to handle stability here. If the picked edition is unstable, we should throw an error if the compiler is not nightly.
You can add a
.stable()
method toEdition
that returns true for 2015.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I know if the compiler is nightly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, found it