-
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
Conversation
src/librustc/session/config.rs
Outdated
@@ -2422,6 +2427,11 @@ mod dep_tracking { | |||
} | |||
} | |||
|
|||
pub fn edition_name_list() -> String { |
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.
Would really love some guidance here. This function really needs to return a &'static str
but I'm not sure how to do that. Any thoughts?
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.
Must it return a 'static str
? There's no way to do this without some unsafe code or hardcoding it.
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.
So the reason I think it needs to be 'static str
is that on line 1646, opt::opt_s
requires that the "valid options string" be of type &'static str
. Is there some way to generate this String while:
- Not introducing something that needs to change whenever we add a new edition in the
libsyntax/edition.rs
file. - And generating a string that is of type
&'static str
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/librustc/session/config.rs
Outdated
@@ -410,6 +412,7 @@ top_level_options!( | |||
|
|||
// Remap source path prefixes in all output (messages, object files, debug, etc) | |||
remap_path_prefix: Vec<(PathBuf, PathBuf)> [UNTRACKED], | |||
edition: Edition [UNTRACKED], |
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.
I think this needs to be TRACKED?
this is for incremental compilation; changing this should probably force a recompile
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.
Ah, so that's the the TRACKED/UNTRACKED thing means. Cool. I'll change this.
src/librustc/session/config.rs
Outdated
@@ -2422,6 +2427,11 @@ mod dep_tracking { | |||
} | |||
} | |||
|
|||
pub fn edition_name_list() -> String { |
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.
Must it return a 'static str
? There's no way to do this without some unsafe code or hardcoding it.
Err(_) => early_error( | ||
ErrorOutputType::default(), | ||
&format!( | ||
"argument for --edition must be one of: \ |
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 to Edition
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
…e editions are allowed to be used on non-nightly builds
} | ||
|
||
// 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 comment
The 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 comment
The 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.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
(ping me when this is ready to review) |
Ah, it is, you just need to fix up some rustdoc code it seems. lmk when travis passes |
You also need to update some tests that use -Zedition |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r+ Hopefully Travis passes, if it doesn't, r- it? |
📌 Commit c8c9bf9 has been approved by |
add --edition option This adds an official `edition` flag to the rust compiler
☀️ Test successful - status-appveyor, status-travis |
Fix cargo to use this? |
This adds an official
edition
flag to the rust compiler