Skip to content

Unsupport the await!(future) macro #62293

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

Merged
merged 4 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adjust tests. wrt. await_macro being removed.
  • Loading branch information
Centril committed Jul 30, 2019
commit 581f2cbfe98b9dae3e353c3a9a5a7aa422bc4954
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]
#![allow(non_camel_case_types)]
#![deny(keyword_idents)]

Expand Down Expand Up @@ -29,6 +29,9 @@ macro_rules! await {
}

fn main() {
await!(); //~ ERROR `await` is a keyword in the 2018 edition
//~^ WARN this was previously accepted by the compiler

match await { await => {} } //~ ERROR `await` is a keyword in the 2018 edition
//~^ ERROR `await` is a keyword in the 2018 edition
//~^^ WARN this was previously accepted by the compiler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-in-non-macro-position.rs:6:13
--> $DIR/2015-edition-error-various-positions.rs:6: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-error-in-non-macro-position.rs:3:9
--> $DIR/2015-edition-error-various-positions.rs:3: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-error-in-non-macro-position.rs:8:20
--> $DIR/2015-edition-error-various-positions.rs:8:20
|
LL | pub struct await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -22,7 +22,7 @@ LL | pub struct await;
= 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-in-non-macro-position.rs:12:16
--> $DIR/2015-edition-error-various-positions.rs:12:16
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -31,7 +31,7 @@ LL | use outer_mod::await::await;
= 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-in-non-macro-position.rs:12:23
--> $DIR/2015-edition-error-various-positions.rs:12:23
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -40,7 +40,7 @@ LL | use outer_mod::await::await;
= 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-in-non-macro-position.rs:17:14
--> $DIR/2015-edition-error-various-positions.rs:17:14
|
LL | struct Foo { await: () }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -49,7 +49,7 @@ LL | struct Foo { await: () }
= 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-in-non-macro-position.rs:21:15
--> $DIR/2015-edition-error-various-positions.rs:21:15
|
LL | impl Foo { fn await() {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -58,7 +58,7 @@ LL | impl Foo { fn await() {} }
= 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-in-non-macro-position.rs:25:14
--> $DIR/2015-edition-error-various-positions.rs:25:14
|
LL | macro_rules! await {
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -67,7 +67,16 @@ LL | macro_rules! await {
= 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-in-non-macro-position.rs:32:11
--> $DIR/2015-edition-error-various-positions.rs:32:5
|
LL | 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-error-various-positions.rs:35:11
|
LL | match await { await => {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -76,13 +85,13 @@ LL | match await { await => {} }
= 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-in-non-macro-position.rs:32:19
--> $DIR/2015-edition-error-various-positions.rs:35: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 9 previous errors
error: aborting due to 10 previous errors

6 changes: 5 additions & 1 deletion src/test/ui/async-await/await-keyword/2018-edition-error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ mod outer_mod {
use self::outer_mod::await::await; //~ ERROR expected identifier
//~^ ERROR expected identifier, found reserved keyword `await`

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

fn main() {
await!(); //~ ERROR expected expression, found `)`
}
18 changes: 17 additions & 1 deletion src/test/ui/async-await/await-keyword/2018-edition-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,21 @@ help: you can escape reserved keywords to use them as identifiers
LL | use self::outer_mod::await::r#await;
| ^^^^^^^

error: aborting due to 4 previous errors
error: expected identifier, found reserved keyword `await`
--> $DIR/2018-edition-error.rs:12:14
|
LL | macro_rules! await { () => {}; }
| ^^^^^ expected identifier, found reserved keyword
help: you can escape reserved keywords to use them as identifiers
|
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

Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ fn foo25() -> Result<(), ()> {
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 `=>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,46 @@ error: incorrect use of `await`
LL | let _ = bar().await()?;
| ^^ help: `await` is not a method call, remove the parentheses

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:112:13
|
LL | let _ = await!(bar())?;
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`

error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:117:17
|
LL | let _ = await!(bar())?;
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`

error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:125:17
|
LL | let _ = await!(bar())?;
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`

error: expected expression, found `=>`
--> $DIR/incorrect-syntax-suggestions.rs:108:25
--> $DIR/incorrect-syntax-suggestions.rs:133:25
|
LL | match await { await => () }
| ----- ^^ expected expression
| |
| while parsing this incorrect await expression

error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:108:11
--> $DIR/incorrect-syntax-suggestions.rs:133: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:111:1
--> $DIR/incorrect-syntax-suggestions.rs:136:1
|
LL | match await { await => () }
| ----- - expected one of `.`, `?`, `{`, or an operator here
Expand Down Expand Up @@ -193,6 +217,22 @@ LL | let foo = || {
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:117:17
|
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:125:17
|
LL | let foo = || {
| -- this is not `async`
LL | let _ = await!(bar())?;
| ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks

error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
--> $DIR/incorrect-syntax-suggestions.rs:18:19
|
Expand All @@ -202,6 +242,6 @@ LL | let _ = await bar()?;
= help: the trait `std::ops::Try` is not implemented for `impl std::future::Future`
= note: required by `std::ops::Try::into_result`

error: aborting due to 29 previous errors
error: aborting due to 35 previous errors

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ error: expected expression, found `)`
--> $DIR/post_expansion_error.rs:8:12
|
LL | await!()
| ----- ^ expected expression
| |
| while parsing this await macro call
| ^ expected expression

error: aborting due to previous error

Loading