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.