Closed
Description
Given the following code (playground link):
async fn func() -> Result<u16, u64> {
let _ = async {
Err(42u64)
}.await?;
Ok(())
}
The current output is:
error[E0308]: mismatched types
--> src/lib.rs:6:8
|
6 | Ok(())
| ^^ expected `u16`, found `()`
|
note: return type inferred to be `u16` here
--> src/lib.rs:2:13
|
2 | let _ = async {
| _____________^
3 | | Err(42u64)
4 | | }.await?;
| |____________^
error: aborting due to previous error
An even more minimal example:
async fn func() -> Result<u16, u64> {
Err(42u64)?;
Ok(())
}
This similarly produces a note pointing to the Err(42u64)?;
line.
The note seems entirely unhelpful here; the function's declared type doesn't match the Ok(())
, and the use of ?
has nothing to do with it. An equivalent non-async function omits the note, and just reports the type mismatch.
The same output occurs on both stable and today's nightly.