1
Fork 0

Rollup merge of #120696 - estebank:issue-115405, r=oli-obk

Properly handle `async` block and `async fn` 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.
This commit is contained in:
Matthias Krüger 2024-02-13 06:27:37 +01:00 committed by GitHub
commit 020e84652d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 227 additions and 59 deletions

View file

@ -617,7 +617,7 @@ impl<'hir> Map<'hir> {
Node::Item(_)
| Node::ForeignItem(_)
| Node::TraitItem(_)
| Node::Expr(Expr { kind: ExprKind::Closure { .. }, .. })
| Node::Expr(Expr { kind: ExprKind::Closure(_), .. })
| Node::ImplItem(_)
// The input node `id` must be enclosed in the method's body as opposed
// to some other place such as its return type (fixes #114918).