-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code:
async fn weird() {
1 = 2;
let mut loop_count = 0;
async {}.await
}
fn main() {}
produces the following errors:
error[E0070]: invalid left-hand side of assignment
--> src/main.rs:2:7
|
2 | 1 = 2;
| - ^
| |
| cannot assign to this expression
error[E0698]: type inside `async fn` body must be known in this context
--> src/main.rs:4:9
|
4 | let mut loop_count = 0;
| ^^^^^^^^^^^^^^ cannot infer type for type `{integer}`
|
note: the type is part of the `async fn` body because of this `await`
--> src/main.rs:5:5
|
5 | async {}.await
| ^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
The "type inside async fn
body must be known in this context" error is spurious, and disappears if the 1 = 2;
line is removed.
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.