fix: Only skip adjustment hints for block, if and match expressions for reborrows

This commit is contained in:
Lukas Wirth 2023-03-13 16:10:49 +01:00
parent 9fca0a4afe
commit 228b44cb18
2 changed files with 45 additions and 11 deletions

View file

@ -356,7 +356,15 @@ impl ast::BlockExpr {
Some(it) => it,
None => return true,
};
!matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR)
match parent.kind() {
FOR_EXPR | IF_EXPR => parent
.children()
.filter(|it| ast::Expr::can_cast(it.kind()))
.next()
.map_or(true, |it| it == *self.syntax()),
LET_ELSE | FN | WHILE_EXPR | LOOP_EXPR | CONST_BLOCK_PAT => false,
_ => true,
}
}
}