-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Make "await" a pseudo-edition keyword #54411
Conversation
This comment has been minimized.
This comment has been minimized.
bfb9249
to
42018e4
Compare
#![allow(non_camel_case_types)] | ||
#![deny(keyword_idents)] | ||
|
||
mod outer_mod { |
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.
It'd be good to make this a "rustfix" test, just to be sure. Just add // run-rustfix
and then re-run with --bless
. This will make a .fixed
file to sure the effect of the suggestions.
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.
Done.
src/libsyntax/feature_gate.rs
Outdated
// a custom error if `await` is used as an identifier on the | ||
// 2018 edition or later and the `async_await` feature isn't | ||
// enabled. | ||
if ident.name == "await" |
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 have a vague fear that this may not work for some uses, because it runs post-expansion.
For example, what if I have (in a Rust 2018 crate):
macro_rules! r#await {
() => { println!("Hello, world!") }
}
fn main() { await!(); }
Does that error?
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.
This is why I was considering saying that we should adapt the keyword warning lint we use for migrating to give a hard error in this case.
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.
Originally I made the code in the lint issue an error, but then I discovered that issuing an error (by setting diagnostic.level = Level::Error
) from the context of a lint won't give you any error output if the compilation fails unless the lint is enabled-- it will just print out "error: ". You're right, though, that that example might not work, so I'll try it out and see if I can hack around the diagnostic builder in the lint code.
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.
Heh, actually, your example does error-- but not where it should:
error[E0721]: `await` is a keyword in the 2018 edition
--> $DIR/async_keyword_again.rs:3:14
|
LL | macro_rules! r#await {
| ^^^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
|
= help: if you were trying to use async/await!, add #![feature(async_await)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0721`.
I'll look into changing the lint.
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.
Done.
☔ The latest upstream changes (presumably #54457) made this pull request unmergeable. Please resolve the merge conflicts. |
42018e4
to
de9c5ca
Compare
This change makes "await" ident an error in 2018 edition without async_await feature and adds "await" to the 2018 edition keyword lint group that suggest migration on the 2015 edition.
de9c5ca
to
fb14662
Compare
@bors r+ p=1 |
📌 Commit fb14662 has been approved by |
Tagging as p=1 b/c this is an Edition feature |
⌛ Testing commit fb14662 with merge f4d0894c9192326fa9e1c11721364fc4bdd745a7... |
💔 Test failed - status-travis |
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 retry Looks flakey |
Make "await" a pseudo-edition keyword This change makes "await" ident an error in 2018 edition without async_await feature and adds "await" to the 2018 edition keyword lint group that suggest migration on the 2015 edition. cc #53834 r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
Tested with: rustc 1.31.0-nightly (8c4ad4e9e 2018-10-04) The changes are mainly about the Rust 2018 transition: - Stopped using `await` as an identifier since it's been reserved as a placeholder for a potential keyword and causes a hard error (rust-lang/rust#54411). - Removed redundant lifetime bounds.
This change makes "await" ident an error in 2018 edition without async_await
feature and adds "await" to the 2018 edition keyword lint group that
suggest migration on the 2015 edition.
cc #53834
r? @nikomatsakis