forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
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#121664 - compiler-errors:adjust-error-yield-lowering, r=spastorino Adjust error `yield`/`await` lowering Adjust the lowering of `yield`/`await` outside of their correct scopes so that we no longer make orpan HIR exprs. Previously, `yield EXPR` would be lowered directly to `hir::TyKind::Error` (which I'll call `<error>`) which means that `EXPR` was not present in the HIR, but now we lower it to `{ EXPR; <error> }` so that `EXPR` is not orphaned. Fixes rust-lang#121096
- Loading branch information
Showing
3 changed files
with
64 additions
and
9 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,9 @@ | ||
//@ edition:2021 | ||
|
||
fn main() { | ||
async { | ||
use std::ops::Add; | ||
let _ = 1.add(3); | ||
}.await | ||
//~^ ERROR `await` is only allowed inside `async` functions and blocks | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/ui/async-await/async-outside-of-await-issue-121096.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,12 @@ | ||
error[E0728]: `await` is only allowed inside `async` functions and blocks | ||
--> $DIR/async-outside-of-await-issue-121096.rs:7:7 | ||
| | ||
LL | fn main() { | ||
| ---- this is not `async` | ||
... | ||
LL | }.await | ||
| ^^^^^ only allowed inside `async` functions and blocks | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0728`. |