diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/async-await/await-keyword | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/async-await/await-keyword')
13 files changed, 814 insertions, 0 deletions
diff --git a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs new file mode 100644 index 000000000..50c163999 --- /dev/null +++ b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs @@ -0,0 +1,38 @@ +#![allow(non_camel_case_types)] +#![deny(keyword_idents)] + +mod outer_mod { + pub mod await { //~ ERROR `await` is a keyword in the 2018 edition + //~^ WARN this is accepted in the current edition + pub struct await; //~ ERROR `await` is a keyword in the 2018 edition + //~^ WARN this is accepted in the current edition + } +} +use outer_mod::await::await; //~ ERROR `await` is a keyword in the 2018 edition +//~^ ERROR `await` is a keyword in the 2018 edition +//~^^ WARN this is accepted in the current edition +//~^^^ WARN this is accepted in the current edition + +struct Foo { await: () } +//~^ ERROR `await` is a keyword in the 2018 edition +//~^^ WARN this is accepted in the current edition + +impl Foo { fn await() {} } +//~^ ERROR `await` is a keyword in the 2018 edition +//~^^ WARN this is accepted in the current edition + +macro_rules! await { +//~^ ERROR `await` is a keyword in the 2018 edition +//~^^ WARN this is accepted in the current edition + () => {} +} + +fn main() { + await!(); //~ ERROR `await` is a keyword in the 2018 edition + //~^ WARN this is accepted in the current edition + + match await { await => {} } //~ ERROR `await` is a keyword in the 2018 edition + //~^ ERROR `await` is a keyword in the 2018 edition + //~^^ WARN this is accepted in the current edition + //~^^^ WARN this is accepted in the current edition +} diff --git a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr new file mode 100644 index 000000000..d99967eb2 --- /dev/null +++ b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr @@ -0,0 +1,97 @@ +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-error-various-positions.rs:5:13 + | +LL | pub mod await { + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> +note: the lint level is defined here + --> $DIR/2015-edition-error-various-positions.rs:2:9 + | +LL | #![deny(keyword_idents)] + | ^^^^^^^^^^^^^^ + +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-error-various-positions.rs:7:20 + | +LL | pub struct await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:11:16 + | +LL | use outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:11:23 + | +LL | use outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:16:14 + | +LL | struct Foo { await: () } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:20:15 + | +LL | impl Foo { fn await() {} } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:24:14 + | +LL | macro_rules! await { + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:31:5 + | +LL | await!(); + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:34:11 + | +LL | match await { await => {} } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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-error-various-positions.rs:34:19 + | +LL | match await { await => {} } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> + +error: aborting due to 10 previous errors + diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.fixed b/tests/ui/async-await/await-keyword/2015-edition-warning.fixed new file mode 100644 index 000000000..117495e13 --- /dev/null +++ b/tests/ui/async-await/await-keyword/2015-edition-warning.fixed @@ -0,0 +1,27 @@ +// run-rustfix + +#![allow(non_camel_case_types)] +#![deny(keyword_idents)] + +mod outer_mod { + pub mod r#await { +//~^ ERROR `await` is a keyword +//~| WARN this is accepted in the current edition + pub struct r#await; +//~^ ERROR `await` is a keyword +//~| WARN this is accepted in the current edition + } +} +use outer_mod::r#await::r#await; +//~^ ERROR `await` is a keyword +//~| ERROR `await` is a keyword +//~| WARN this is accepted in the current edition +//~| WARN this is accepted in the current edition + +fn main() { + match r#await { r#await => {} } +//~^ ERROR `await` is a keyword +//~| ERROR `await` is a keyword +//~| WARN this is accepted in the current edition +//~| WARN this is accepted in the current edition +} diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.rs b/tests/ui/async-await/await-keyword/2015-edition-warning.rs new file mode 100644 index 000000000..b3c64895c --- /dev/null +++ b/tests/ui/async-await/await-keyword/2015-edition-warning.rs @@ -0,0 +1,27 @@ +// run-rustfix + +#![allow(non_camel_case_types)] +#![deny(keyword_idents)] + +mod outer_mod { + pub mod await { +//~^ ERROR `await` is a keyword +//~| WARN this is accepted in the current edition + pub struct await; +//~^ ERROR `await` is a keyword +//~| WARN this is accepted in the current edition + } +} +use outer_mod::await::await; +//~^ ERROR `await` is a keyword +//~| ERROR `await` is a keyword +//~| WARN this is accepted in the current edition +//~| WARN this is accepted in the current edition + +fn main() { + match await { await => {} } +//~^ ERROR `await` is a keyword +//~| ERROR `await` is a keyword +//~| WARN this is accepted in the current edition +//~| WARN this is accepted in the current edition +} diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.stderr b/tests/ui/async-await/await-keyword/2015-edition-warning.stderr new file mode 100644 index 000000000..bf5c4d8d6 --- /dev/null +++ b/tests/ui/async-await/await-keyword/2015-edition-warning.stderr @@ -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` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> +note: the lint level is defined here + --> $DIR/2015-edition-warning.rs:4:9 + | +LL | #![deny(keyword_idents)] + | ^^^^^^^^^^^^^^ + +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-warning.rs:10:20 + | +LL | pub struct await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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:15:16 + | +LL | use outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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:15:23 + | +LL | use outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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:22:11 + | +LL | match await { await => {} } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = 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:22:19 + | +LL | match await { await => {} } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> + +error: aborting due to 6 previous errors + diff --git a/tests/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.rs b/tests/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.rs new file mode 100644 index 000000000..9e78f7c51 --- /dev/null +++ b/tests/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.rs @@ -0,0 +1,24 @@ +// edition:2018 + +#![allow(non_camel_case_types)] + +mod outer_mod { + 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 keyword `await` +//~^ ERROR expected identifier, found keyword `await` + +struct Foo { await: () } +//~^ ERROR expected identifier, found keyword `await` + +impl Foo { fn await() {} } +//~^ ERROR expected identifier, found keyword `await` + +macro_rules! await { +//~^ ERROR expected identifier, found keyword `await` + () => {} +} + +fn main() {} diff --git a/tests/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.stderr b/tests/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.stderr new file mode 100644 index 000000000..6bd8f671d --- /dev/null +++ b/tests/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.stderr @@ -0,0 +1,81 @@ +error: expected identifier, found keyword `await` + --> $DIR/2018-edition-error-in-non-macro-position.rs:6:13 + | +LL | pub mod await { + | ^^^^^ expected identifier, found keyword + | +help: escape `await` to use it as an identifier + | +LL | pub mod r#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 keyword + | +help: escape `await` to use it as an identifier + | +LL | pub struct r#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 keyword + | +help: escape `await` to use it as an identifier + | +LL | use self::outer_mod::r#await::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 keyword + | +help: escape `await` to use it as an identifier + | +LL | use self::outer_mod::await::r#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 keyword + | | + | while parsing this struct + | +help: escape `await` to use it as an identifier + | +LL | struct Foo { r#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 keyword + | +help: escape `await` to use it as an identifier + | +LL | impl Foo { fn r#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 keyword + | +help: escape `await` to use it as an identifier + | +LL | macro_rules! r#await { + | ++ + +error: aborting due to 7 previous errors + diff --git a/tests/ui/async-await/await-keyword/2018-edition-error.rs b/tests/ui/async-await/await-keyword/2018-edition-error.rs new file mode 100644 index 000000000..7ce52259a --- /dev/null +++ b/tests/ui/async-await/await-keyword/2018-edition-error.rs @@ -0,0 +1,16 @@ +// edition:2018 +#![allow(non_camel_case_types)] + +mod outer_mod { + pub mod await { //~ ERROR expected identifier + pub struct await; //~ ERROR expected identifier + } +} +use self::outer_mod::await::await; //~ ERROR expected identifier + //~^ ERROR expected identifier, found keyword `await` + +macro_rules! await { () => {}; } //~ ERROR expected identifier, found keyword `await` + +fn main() { + await!(); //~ ERROR expected expression, found `)` +} diff --git a/tests/ui/async-await/await-keyword/2018-edition-error.stderr b/tests/ui/async-await/await-keyword/2018-edition-error.stderr new file mode 100644 index 000000000..34bfdfc71 --- /dev/null +++ b/tests/ui/async-await/await-keyword/2018-edition-error.stderr @@ -0,0 +1,63 @@ +error: expected identifier, found keyword `await` + --> $DIR/2018-edition-error.rs:5:13 + | +LL | pub mod await { + | ^^^^^ expected identifier, found keyword + | +help: escape `await` to use it as an identifier + | +LL | pub mod r#await { + | ++ + +error: expected identifier, found keyword `await` + --> $DIR/2018-edition-error.rs:6:20 + | +LL | pub struct await; + | ^^^^^ expected identifier, found keyword + | +help: escape `await` to use it as an identifier + | +LL | pub struct r#await; + | ++ + +error: expected identifier, found keyword `await` + --> $DIR/2018-edition-error.rs:9:22 + | +LL | use self::outer_mod::await::await; + | ^^^^^ expected identifier, found keyword + | +help: escape `await` to use it as an identifier + | +LL | use self::outer_mod::r#await::await; + | ++ + +error: expected identifier, found keyword `await` + --> $DIR/2018-edition-error.rs:9:29 + | +LL | use self::outer_mod::await::await; + | ^^^^^ expected identifier, found keyword + | +help: escape `await` to use it as an identifier + | +LL | use self::outer_mod::await::r#await; + | ++ + +error: expected identifier, found keyword `await` + --> $DIR/2018-edition-error.rs:12:14 + | +LL | macro_rules! await { () => {}; } + | ^^^^^ expected identifier, found keyword + | +help: escape `await` to use it as an identifier + | +LL | macro_rules! r#await { () => {}; } + | ++ + +error: expected expression, found `)` + --> $DIR/2018-edition-error.rs:15:12 + | +LL | await!(); + | ^ expected expression + +error: aborting due to 6 previous errors + diff --git a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs new file mode 100644 index 000000000..554ac673d --- /dev/null +++ b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs @@ -0,0 +1,132 @@ +// edition:2018 + +async fn bar() -> Result<(), ()> { + Ok(()) +} + +async fn foo1() -> Result<(), ()> { + let _ = await bar(); //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo2() -> Result<(), ()> { + let _ = await? bar(); //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo3() -> Result<(), ()> { + let _ = await bar()?; //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo21() -> Result<(), ()> { + let _ = await { bar() }; //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo22() -> Result<(), ()> { + let _ = await(bar()); //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo23() -> Result<(), ()> { + let _ = await { bar() }?; //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo4() -> Result<(), ()> { + let _ = (await bar())?; //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo5() -> Result<(), ()> { + let _ = bar().await(); //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo6() -> Result<(), ()> { + let _ = bar().await()?; //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo7() -> Result<(), ()> { + let _ = bar().await; // OK + Ok(()) +} +async fn foo8() -> Result<(), ()> { + let _ = bar().await?; // OK + Ok(()) +} +fn foo9() -> Result<(), ()> { + let _ = await bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks + //~^ ERROR incorrect use of `await` + Ok(()) +} +fn foo10() -> Result<(), ()> { + let _ = await? bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks + //~^ ERROR incorrect use of `await` + Ok(()) +} +fn foo11() -> Result<(), ()> { + let _ = await bar()?; //~ ERROR incorrect use of `await` + Ok(()) +} +fn foo12() -> Result<(), ()> { + let _ = (await bar())?; //~ ERROR `await` is only allowed inside `async` functions and blocks + //~^ ERROR incorrect use of `await` + Ok(()) +} +fn foo13() -> Result<(), ()> { + let _ = bar().await(); //~ ERROR `await` is only allowed inside `async` functions and blocks + //~^ ERROR incorrect use of `await` + Ok(()) +} +fn foo14() -> Result<(), ()> { + let _ = bar().await()?; //~ ERROR `await` is only allowed inside `async` functions and blocks + //~^ ERROR incorrect use of `await` + Ok(()) +} +fn foo15() -> Result<(), ()> { + let _ = bar().await; //~ ERROR `await` is only allowed inside `async` functions and blocks + Ok(()) +} +fn foo16() -> Result<(), ()> { + let _ = bar().await?; //~ ERROR `await` is only allowed inside `async` functions and blocks + Ok(()) +} +fn foo24() -> Result<(), ()> { + fn foo() -> Result<(), ()> { + let _ = bar().await?; //~ ERROR `await` is only allowed inside `async` functions and blocks + Ok(()) + } + foo() +} +fn foo25() -> Result<(), ()> { + let foo = || { + let _ = bar().await?; //~ ERROR `await` is only allowed inside `async` functions and blocks + Ok(()) + }; + foo() +} + +async fn foo26() -> Result<(), ()> { + let _ = await!(bar()); //~ ERROR incorrect use of `await` + Ok(()) +} +async fn foo27() -> Result<(), ()> { + let _ = await!(bar())?; //~ ERROR incorrect use of `await` + Ok(()) +} +fn foo28() -> Result<(), ()> { + fn foo() -> Result<(), ()> { + let _ = await!(bar())?; //~ ERROR incorrect use of `await` + //~^ ERROR `await` is only allowed inside `async` functions + Ok(()) + } + foo() +} +fn foo29() -> Result<(), ()> { + let foo = || { + let _ = await!(bar())?; //~ ERROR incorrect use of `await` + //~^ ERROR `await` is only allowed inside `async` functions + Ok(()) + }; + foo() +} + +fn main() { + match await { await => () } + //~^ ERROR expected expression, found `=>` + //~| ERROR incorrect use of `await` +} //~ ERROR expected one of `.`, `?`, `{`, or an operator, found `}` diff --git a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr new file mode 100644 index 000000000..b30f28837 --- /dev/null +++ b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr @@ -0,0 +1,230 @@ +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:8:13 + | +LL | let _ = await bar(); + | ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:12:13 + | +LL | let _ = await? bar(); + | ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await?` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:16:13 + | +LL | let _ = await bar()?; + | ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar()?.await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:20:13 + | +LL | let _ = await { bar() }; + | ^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ bar() }.await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:24:13 + | +LL | let _ = await(bar()); + | ^^^^^^^^^^^^ help: `await` is a postfix operation: `(bar()).await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:28:13 + | +LL | let _ = await { bar() }?; + | ^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ bar() }.await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:32:14 + | +LL | let _ = (await bar())?; + | ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:36:24 + | +LL | let _ = bar().await(); + | ^^ help: `await` is not a method call, remove the parentheses + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:40:24 + | +LL | let _ = bar().await()?; + | ^^ help: `await` is not a method call, remove the parentheses + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:52:13 + | +LL | let _ = await bar(); + | ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:57:13 + | +LL | let _ = await? bar(); + | ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await?` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:62:13 + | +LL | let _ = await bar()?; + | ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar()?.await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:66:14 + | +LL | let _ = (await bar())?; + | ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:71:24 + | +LL | let _ = bar().await(); + | ^^ help: `await` is not a method call, remove the parentheses + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:76:24 + | +LL | let _ = bar().await()?; + | ^^ help: `await` is not a method call, remove the parentheses + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:104:13 + | +LL | let _ = await!(bar()); + | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:108:13 + | +LL | let _ = await!(bar())?; + | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:113:17 + | +LL | let _ = await!(bar())?; + | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:121:17 + | +LL | let _ = await!(bar())?; + | ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await` + +error: expected expression, found `=>` + --> $DIR/incorrect-syntax-suggestions.rs:129:25 + | +LL | match await { await => () } + | ----- ^^ expected expression + | | + | while parsing this incorrect await expression + +error: incorrect use of `await` + --> $DIR/incorrect-syntax-suggestions.rs:129:11 + | +LL | match await { await => () } + | ^^^^^^^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ await => () }.await` + +error: expected one of `.`, `?`, `{`, or an operator, found `}` + --> $DIR/incorrect-syntax-suggestions.rs:132:1 + | +LL | match await { await => () } + | ----- - expected one of `.`, `?`, `{`, or an operator + | | + | while parsing this `match` expression +... +LL | } + | ^ unexpected token + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:52:13 + | +LL | fn foo9() -> Result<(), ()> { + | ---- this is not `async` +LL | let _ = await bar(); + | ^^^^^^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:57:13 + | +LL | fn foo10() -> Result<(), ()> { + | ----- this is not `async` +LL | let _ = await? bar(); + | ^^^^^^^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:66:14 + | +LL | fn foo12() -> Result<(), ()> { + | ----- this is not `async` +LL | let _ = (await bar())?; + | ^^^^^^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:71:18 + | +LL | fn foo13() -> Result<(), ()> { + | ----- this is not `async` +LL | let _ = bar().await(); + | ^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:76:18 + | +LL | fn foo14() -> Result<(), ()> { + | ----- this is not `async` +LL | let _ = bar().await()?; + | ^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:81:18 + | +LL | fn foo15() -> Result<(), ()> { + | ----- this is not `async` +LL | let _ = bar().await; + | ^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:85:18 + | +LL | fn foo16() -> Result<(), ()> { + | ----- this is not `async` +LL | let _ = bar().await?; + | ^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:90:22 + | +LL | fn foo() -> Result<(), ()> { + | --- this is not `async` +LL | let _ = bar().await?; + | ^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:97:22 + | +LL | let foo = || { + | -- this is not `async` +LL | let _ = bar().await?; + | ^^^^^^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:113:29 + | +LL | fn foo() -> Result<(), ()> { + | --- this is not `async` +LL | let _ = await!(bar())?; + | ^ only allowed inside `async` functions and blocks + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/incorrect-syntax-suggestions.rs:121:29 + | +LL | let foo = || { + | -- this is not `async` +LL | let _ = await!(bar())?; + | ^ only allowed inside `async` functions and blocks + +error: aborting due to 33 previous errors + +For more information about this error, try `rustc --explain E0728`. diff --git a/tests/ui/async-await/await-keyword/post_expansion_error.rs b/tests/ui/async-await/await-keyword/post_expansion_error.rs new file mode 100644 index 000000000..b4c899b0d --- /dev/null +++ b/tests/ui/async-await/await-keyword/post_expansion_error.rs @@ -0,0 +1,10 @@ +// edition:2018 + +macro_rules! r#await { + () => { println!("Hello, world!") } +} + +fn main() { + await!() + //~^ ERROR expected expression, found `)` +} diff --git a/tests/ui/async-await/await-keyword/post_expansion_error.stderr b/tests/ui/async-await/await-keyword/post_expansion_error.stderr new file mode 100644 index 000000000..0996c38b3 --- /dev/null +++ b/tests/ui/async-await/await-keyword/post_expansion_error.stderr @@ -0,0 +1,8 @@ +error: expected expression, found `)` + --> $DIR/post_expansion_error.rs:8:12 + | +LL | await!() + | ^ expected expression + +error: aborting due to previous error + |