From 37d2ea2fa064411de78ec24a178a05dc02517673 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Tue, 6 Feb 2024 03:30:16 +0000 Subject: Properly handle `async` blocks and `fn`s in `if` exprs without `else` 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. --- tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/ui/impl-trait') diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr index 77f6945f064..9fa73d817ca 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr @@ -1,6 +1,8 @@ error[E0308]: mismatched types --> $DIR/default-body-type-err-2.rs:7:9 | +LL | async fn woopsie_async(&self) -> String { + | ------ expected `String` because of return type LL | 42 | ^^- help: try using a conversion method: `.to_string()` | | -- cgit 1.4.1-3-g733a5