-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #54411 - cramertj:await-keyword-error, r=nikomatsakis
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
- Loading branch information
Showing
12 changed files
with
244 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
register_diagnostics! { | ||
E0721, // `await` keyword | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// compile-pass | ||
|
||
#![feature(async_await)] | ||
#![allow(non_camel_case_types)] | ||
#![deny(keyword_idents)] | ||
|
||
mod outer_mod { | ||
pub mod await { | ||
pub struct await; | ||
} | ||
} | ||
use outer_mod::await::await; | ||
|
||
fn main() { | ||
match await { await => {} } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
|
||
#![allow(non_camel_case_types)] | ||
#![deny(keyword_idents)] | ||
|
||
mod outer_mod { | ||
pub mod r#await { | ||
pub struct r#await; | ||
} | ||
} | ||
use outer_mod::r#await::r#await; | ||
|
||
fn main() { | ||
match r#await { r#await => {} } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
|
||
#![allow(non_camel_case_types)] | ||
#![deny(keyword_idents)] | ||
|
||
mod outer_mod { | ||
pub mod await { | ||
pub struct await; | ||
} | ||
} | ||
use outer_mod::await::await; | ||
|
||
fn main() { | ||
match await { await => {} } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-warning.rs:7:13 | ||
| | ||
LL | pub mod await { | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
note: lint level defined here | ||
--> $DIR/2015-edition-warning.rs:4:9 | ||
| | ||
LL | #![deny(keyword_idents)] | ||
| ^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-warning.rs:8:20 | ||
| | ||
LL | pub struct await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-warning.rs:11:16 | ||
| | ||
LL | use outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-warning.rs:11:23 | ||
| | ||
LL | use outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-warning.rs:14:11 | ||
| | ||
LL | match await { await => {} } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: `await` is a keyword in the 2018 edition | ||
--> $DIR/2015-edition-warning.rs:14:19 | ||
| | ||
LL | match await { await => {} } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> | ||
|
||
error: aborting due to 6 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// edition:2018 | ||
#![allow(non_camel_case_types)] | ||
|
||
mod outer_mod { | ||
pub mod await { | ||
pub struct await; | ||
} | ||
} | ||
use self::outer_mod::await::await; | ||
|
||
fn main() { | ||
match await { await => () } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:5:13 | ||
| | ||
LL | pub mod await { | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:6:20 | ||
| | ||
LL | pub struct await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:9:22 | ||
| | ||
LL | use self::outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:9:29 | ||
| | ||
LL | use self::outer_mod::await::await; | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:12:11 | ||
| | ||
LL | match await { await => () } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/2018-edition-error.rs:12:19 | ||
| | ||
LL | match await { await => () } | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0721`. |
16 changes: 16 additions & 0 deletions
16
src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// compile-pass | ||
// edition:2018 | ||
|
||
#![allow(non_camel_case_types)] | ||
#![feature(async_await)] | ||
|
||
mod outer_mod { | ||
pub mod await { | ||
pub struct await; | ||
} | ||
} | ||
use self::outer_mod::await::await; | ||
|
||
fn main() { | ||
match await { await => () } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// edition:2018 | ||
|
||
macro_rules! r#await { | ||
() => { println!("Hello, world!") } | ||
} | ||
|
||
fn main() { | ||
await!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0721]: `await` is a keyword in the 2018 edition | ||
--> $DIR/post_expansion_error.rs:8:5 | ||
| | ||
LL | await!() | ||
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0721`. |