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#118419 - compiler-errors:await-span2, r=cjg…
…illot Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context This PR does 2 things: 1. Refuses to lower `.await` or `yield` when we are outside of the right coroutine context for the operator. Instead, we lower to `hir::ExprKind::Err`, to silence subsequent redundant errors. 2. Reworks a bit of the span tracking in `LoweringContext` to fix a bad span when we have something like `let x = [0; async_fn().await]` where the `await` is inside of an anon const. The span for the "item" still kinda sucks, since it overlaps with the `await` span, but at least it's accurate.
- Loading branch information
Showing
11 changed files
with
36 additions
and
85 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
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
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
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
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 |
---|---|---|
@@ -1,37 +1,12 @@ | ||
error[E0728]: `await` is only allowed inside `async` functions and blocks | ||
--> $DIR/issue-70594.rs:4:12 | ||
| | ||
LL | async fn fun() { | ||
| --- this is not `async` | ||
LL | [1; ().await]; | ||
| ^^^^^ only allowed inside `async` functions and blocks | ||
| ---^^^^^ | ||
| | | | ||
| | only allowed inside `async` functions and blocks | ||
| this is not `async` | ||
|
||
error[E0744]: `.await` is not allowed in a `const` | ||
--> $DIR/issue-70594.rs:4:9 | ||
| | ||
LL | [1; ().await]; | ||
| ^^^^^^^^ | ||
|
||
error[E0744]: `.await` is not allowed in a `const` | ||
--> $DIR/issue-70594.rs:4:12 | ||
| | ||
LL | [1; ().await]; | ||
| ^^^^^ | ||
|
||
error[E0277]: `()` is not a future | ||
--> $DIR/issue-70594.rs:4:12 | ||
| | ||
LL | [1; ().await]; | ||
| -^^^^^ | ||
| || | ||
| |`()` is not a future | ||
| help: remove the `.await` | ||
| | ||
= help: the trait `Future` is not implemented for `()` | ||
= note: () must be a future or must implement `IntoFuture` to be awaited | ||
= note: required for `()` to implement `IntoFuture` | ||
|
||
error: aborting due to 4 previous errors | ||
error: aborting due to 1 previous error | ||
|
||
Some errors have detailed explanations: E0277, E0728, E0744. | ||
For more information about an error, try `rustc --explain E0277`. | ||
For more information about this error, try `rustc --explain E0728`. |
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