37d2ea2fa0
When encountering a tail expression in the then arm of an `if` expression without an `else` arm, account for `async fn` and `async` blocks to suggest `return`ing the value and pointing at the return type of the `async fn`. We now also account for AFIT when looking for the return type to point at. Fix #115405.
36 lines
1023 B
Plaintext
36 lines
1023 B
Plaintext
error[E0308]: mismatched types
|
|
--> $DIR/missing-return-in-async-block.rs:9:13
|
|
|
|
|
LL | / if true {
|
|
LL | | Ok(S)
|
|
| | ^^^^^ expected `()`, found `Result<S, _>`
|
|
LL | | }
|
|
| |_________- expected this to be `()`
|
|
|
|
|
= note: expected unit type `()`
|
|
found enum `Result<S, _>`
|
|
help: you might have meant to return this value
|
|
|
|
|
LL | return Ok(S);
|
|
| ++++++ +
|
|
|
|
error[E0308]: mismatched types
|
|
--> $DIR/missing-return-in-async-block.rs:17:13
|
|
|
|
|
LL | / if true {
|
|
LL | | Ok(S)
|
|
| | ^^^^^ expected `()`, found `Result<S, _>`
|
|
LL | | }
|
|
| |_________- expected this to be `()`
|
|
|
|
|
= note: expected unit type `()`
|
|
found enum `Result<S, _>`
|
|
help: you might have meant to return this value
|
|
|
|
|
LL | return Ok(S);
|
|
| ++++++ +
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0308`.
|