forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#63509 - estebank:async-span, r=Centril
Point at the right enclosing scope when using `await` in non-async fn Fix rust-lang#63398.
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
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
12 changes: 12 additions & 0 deletions
12
src/test/ui/async-await/issues/non-async-enclosing-span.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,12 @@ | ||
// edition:2018 | ||
#![feature(async_await)] | ||
|
||
async fn do_the_thing() -> u8 { | ||
8 | ||
} | ||
// #63398: point at the enclosing scope and not the previously seen closure | ||
fn main() { //~ NOTE this is not `async` | ||
let x = move || {}; | ||
let y = do_the_thing().await; //~ ERROR `await` is only allowed inside `async` functions | ||
//~^ NOTE only allowed inside `async` functions and blocks | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/async-await/issues/non-async-enclosing-span.stderr
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,11 @@ | ||
error[E0728]: `await` is only allowed inside `async` functions and blocks | ||
--> $DIR/non-async-enclosing-span.rs:10:13 | ||
| | ||
LL | fn main() { | ||
| ---- this is not `async` | ||
LL | let x = move || {}; | ||
LL | let y = do_the_thing().await; | ||
| ^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks | ||
|
||
error: aborting due to previous error | ||
|