Skip to content

Commit

Permalink
Upgrade async/await to "used" keywords.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Sep 28, 2019
1 parent f3c8eba commit f6cecce
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 61 deletions.
8 changes: 4 additions & 4 deletions src/libsyntax_pos/symbol.rs
Expand Up @@ -83,11 +83,11 @@ symbols! {
Yield: "yield",

// Edition-specific keywords that are used in stable Rust.
Async: "async", // >= 2018 Edition only
Await: "await", // >= 2018 Edition only
Dyn: "dyn", // >= 2018 Edition only

// Edition-specific keywords that are used in unstable Rust or reserved for future use.
Async: "async", // >= 2018 Edition only
Await: "await", // >= 2018 Edition only
Try: "try", // >= 2018 Edition only

// Special lifetime names
Expand Down Expand Up @@ -1088,11 +1088,11 @@ pub mod sym {

impl Symbol {
fn is_used_keyword_2018(self) -> bool {
self == kw::Dyn
self >= kw::Async && self <= kw::Dyn
}

fn is_unused_keyword_2018(self) -> bool {
self >= kw::Async && self <= kw::Try
self == kw::Try
}

/// Used for sanity checking rustdoc keyword sections.
Expand Down
Expand Up @@ -3,21 +3,21 @@
#![allow(non_camel_case_types)]

mod outer_mod {
pub mod await { //~ ERROR expected identifier, found reserved keyword `await`
pub struct await; //~ ERROR expected identifier, found reserved keyword `await`
pub mod await { //~ ERROR expected identifier, found keyword `await`
pub struct await; //~ ERROR expected identifier, found keyword `await`
}
}
use self::outer_mod::await::await; //~ ERROR expected identifier, found reserved keyword `await`
//~^ ERROR expected identifier, found reserved keyword `await`
use self::outer_mod::await::await; //~ ERROR expected identifier, found keyword `await`
//~^ ERROR expected identifier, found keyword `await`

struct Foo { await: () }
//~^ ERROR expected identifier, found reserved keyword `await`
//~^ ERROR expected identifier, found keyword `await`

impl Foo { fn await() {} }
//~^ ERROR expected identifier, found reserved keyword `await`
//~^ ERROR expected identifier, found keyword `await`

macro_rules! await {
//~^ ERROR expected identifier, found reserved keyword `await`
//~^ ERROR expected identifier, found keyword `await`
() => {}
}

Expand Down
@@ -1,68 +1,68 @@
error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error-in-non-macro-position.rs:6:13
|
LL | pub mod await {
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | pub mod r#await {
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error-in-non-macro-position.rs:7:20
|
LL | pub struct await;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | pub struct r#await;
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error-in-non-macro-position.rs:10:22
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::r#await::await;
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error-in-non-macro-position.rs:10:29
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::await::r#await;
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error-in-non-macro-position.rs:13:14
|
LL | struct Foo { await: () }
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | struct Foo { r#await: () }
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error-in-non-macro-position.rs:16:15
|
LL | impl Foo { fn await() {} }
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | impl Foo { fn r#await() {} }
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error-in-non-macro-position.rs:19:14
|
LL | macro_rules! await {
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | macro_rules! r#await {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/async-await/await-keyword/2018-edition-error.rs
Expand Up @@ -7,9 +7,9 @@ mod outer_mod {
}
}
use self::outer_mod::await::await; //~ ERROR expected identifier
//~^ ERROR expected identifier, found reserved keyword `await`
//~^ ERROR expected identifier, found keyword `await`

macro_rules! await { () => {}; } //~ ERROR expected identifier, found reserved keyword `await`
macro_rules! await { () => {}; } //~ ERROR expected identifier, found keyword `await`

fn main() {
await!(); //~ ERROR expected expression, found `)`
Expand Down
20 changes: 10 additions & 10 deletions src/test/ui/async-await/await-keyword/2018-edition-error.stderr
@@ -1,48 +1,48 @@
error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error.rs:5:13
|
LL | pub mod await {
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | pub mod r#await {
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error.rs:6:20
|
LL | pub struct await;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | pub struct r#await;
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error.rs:9:22
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::r#await::await;
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error.rs:9:29
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::await::r#await;
| ^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/2018-edition-error.rs:12:14
|
LL | macro_rules! await { () => {}; }
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | macro_rules! r#await { () => {}; }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/no-const-async.rs
Expand Up @@ -3,5 +3,5 @@
// compile-flags: --crate-type lib

pub const async fn x() {}
//~^ ERROR expected identifier, found reserved keyword `async`
//~^ ERROR expected identifier, found keyword `async`
//~^^ expected `:`, found keyword `fn`
4 changes: 2 additions & 2 deletions src/test/ui/async-await/no-const-async.stderr
@@ -1,8 +1,8 @@
error: expected identifier, found reserved keyword `async`
error: expected identifier, found keyword `async`
--> $DIR/no-const-async.rs:5:11
|
LL | pub const async fn x() {}
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | pub const r#async fn x() {}
Expand Down
Expand Up @@ -5,7 +5,7 @@
extern crate edition_kw_macro_2018;

mod one_async {
produces_async! {} //~ ERROR expected identifier, found reserved keyword
produces_async! {} //~ ERROR expected identifier, found keyword
}
mod two_async {
produces_async_raw! {} // OK
Expand Down
@@ -1,8 +1,8 @@
error: expected identifier, found reserved keyword `async`
error: expected identifier, found keyword `async`
--> $DIR/edition-keywords-2015-2018-expansion.rs:8:5
|
LL | produces_async! {}
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
| ^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: you can escape reserved keywords to use them as identifiers
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/editions/edition-keywords-2018-2015-parsing.rs
Expand Up @@ -5,7 +5,7 @@
extern crate edition_kw_macro_2015;

pub fn check_async() {
let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async`
let mut async = 1; //~ ERROR expected identifier, found keyword `async`
let mut r#async = 1; // OK

r#async = consumes_async!(async); // OK
Expand All @@ -15,6 +15,6 @@ pub fn check_async() {

if passes_ident!(async) == 1 {}
if passes_ident!(r#async) == 1 {} // OK
module::async(); //~ ERROR expected identifier, found reserved keyword `async`
module::async(); //~ ERROR expected identifier, found keyword `async`
module::r#async(); // OK
}
@@ -1,18 +1,18 @@
error: expected identifier, found reserved keyword `async`
error: expected identifier, found keyword `async`
--> $DIR/edition-keywords-2018-2015-parsing.rs:8:13
|
LL | let mut async = 1;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | let mut r#async = 1;
| ^^^^^^^

error: expected identifier, found reserved keyword `async`
error: expected identifier, found keyword `async`
--> $DIR/edition-keywords-2018-2015-parsing.rs:18:13
|
LL | module::async();
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | module::r#async();
Expand Down
Expand Up @@ -5,7 +5,7 @@
extern crate edition_kw_macro_2018;

mod one_async {
produces_async! {} //~ ERROR expected identifier, found reserved keyword `async`
produces_async! {} //~ ERROR expected identifier, found keyword `async`
}
mod two_async {
produces_async_raw! {} // OK
Expand Down
@@ -1,8 +1,8 @@
error: expected identifier, found reserved keyword `async`
error: expected identifier, found keyword `async`
--> $DIR/edition-keywords-2018-2018-expansion.rs:8:5
|
LL | produces_async! {}
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
| ^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: you can escape reserved keywords to use them as identifiers
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/editions/edition-keywords-2018-2018-parsing.rs
Expand Up @@ -5,7 +5,7 @@
extern crate edition_kw_macro_2018;

pub fn check_async() {
let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async`
let mut async = 1; //~ ERROR expected identifier, found keyword `async`
let mut r#async = 1; // OK

r#async = consumes_async!(async); // OK
Expand All @@ -15,6 +15,6 @@ pub fn check_async() {

if passes_ident!(async) == 1 {}
if passes_ident!(r#async) == 1 {} // OK
module::async(); //~ ERROR expected identifier, found reserved keyword `async`
module::async(); //~ ERROR expected identifier, found keyword `async`
module::r#async(); // OK
}
@@ -1,18 +1,18 @@
error: expected identifier, found reserved keyword `async`
error: expected identifier, found keyword `async`
--> $DIR/edition-keywords-2018-2018-parsing.rs:8:13
|
LL | let mut async = 1;
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | let mut r#async = 1;
| ^^^^^^^

error: expected identifier, found reserved keyword `async`
error: expected identifier, found keyword `async`
--> $DIR/edition-keywords-2018-2018-parsing.rs:18:13
|
LL | module::async();
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | module::r#async();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/mut-patterns.rs
Expand Up @@ -28,7 +28,7 @@ pub fn main() {
//~| ERROR `mut` must be attached to each individual binding
//~| ERROR expected identifier, found reserved keyword `yield`
//~| ERROR expected identifier, found reserved keyword `become`
//~| ERROR expected identifier, found reserved keyword `await`
//~| ERROR expected identifier, found keyword `await`

struct W<T, U>(T, U);
struct B { f: Box<u8> }
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/parser/mut-patterns.stderr
Expand Up @@ -62,11 +62,11 @@ help: you can escape reserved keywords to use them as identifiers
LL | let mut mut yield(r#become, await) = r#yield(0, 0);
| ^^^^^^^^

error: expected identifier, found reserved keyword `await`
error: expected identifier, found keyword `await`
--> $DIR/mut-patterns.rs:26:31
|
LL | let mut mut yield(become, await) = r#yield(0, 0);
| ^^^^^ expected identifier, found reserved keyword
| ^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | let mut mut yield(become, r#await) = r#yield(0, 0);
Expand Down

0 comments on commit f6cecce

Please sign in to comment.