Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d8b89e2ba445cca680d18063b9d62a20
async fn f() -> Result<u8, u16> {
let x = false;
if x {
Ok(0u8)
}
Err(2u16)
}
The current output is:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/lib.rs:4:9
|
3 | / if x {
4 | | Ok(0u8)
| | ^^^^^^^ expected `()`, found enum `Result`
5 | | }
| |_____- expected this to be `()`
|
= note: expected unit type `()`
found enum `Result<u8, _>`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error
Ideally the output should look like it does for the non-async version:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/lib.rs:4:9
|
3 | / if x {
4 | | Ok(0u8)
| | ^^^^^^^ expected `()`, found enum `Result`
5 | | }
| |_____- expected this to be `()`
|
= note: expected unit type `()`
found enum `Result<u8, _>`
help: you might have meant to return this value
|
4 | return Ok(0u8);
| ++++++ +
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsAsync-await issues that are part of the "polish" areaAsync-await issues that have been triaged during a working group meeting.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.