-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in 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
This code:
async fn a() {}
async fn b() -> Result<(), i32> {
a().await
}
produces:
error[E0308]: mismatched types
--> src/main.rs:4:8
|
4 | a().await
| ^^^^^^ expected enum `Result`, found `()`
|
= note: expected enum `Result<(), i32>`
found unit type `()`
help: try wrapping the expression in `Ok`
|
4 | a()Ok(.await)
| +++ +
Which is invalid.
Looks like the span of the desugaring of .await
uses only the .await
part, instead of the span of the entire expression. This results in invalid suggestions when used by the suggest_compatible_variants
code in compiler/rustc_typeck/src/check/demand.rs
.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in 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.