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.
23 lines
463 B
Rust
23 lines
463 B
Rust
// run-rustfix
|
|
// edition:2021
|
|
use std::future::Future;
|
|
use std::pin::Pin;
|
|
pub struct S;
|
|
pub fn foo() {
|
|
let _ = Box::pin(async move {
|
|
if true {
|
|
return Ok(S); //~ ERROR mismatched types
|
|
}
|
|
Err(())
|
|
});
|
|
}
|
|
pub fn bar() -> Pin<Box<dyn Future<Output = Result<S, ()>> + 'static>> {
|
|
Box::pin(async move {
|
|
if true {
|
|
return Ok(S); //~ ERROR mismatched types
|
|
}
|
|
Err(())
|
|
})
|
|
}
|
|
fn main() {}
|