Auto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obk

Fix drop handling for `if let` expressions

MIR lowering for `if let` expressions is now more complicated now that
`if let` exists in HIR. This PR adds a scope for the variables bound in
an `if let` expression and then uses an approach similar to how we
handle loops to ensure that we reliably drop the correct variables.

Closes #88307
cc `@flip1995` `@richkadel` `@c410-f3r`
This commit is contained in:
bors 2021-09-03 20:31:43 +00:00
commit b7404c898a
62 changed files with 617 additions and 583 deletions

View file

@ -1177,6 +1177,7 @@ pub struct Arm<'hir> {
#[derive(Debug, HashStable_Generic)]
pub enum Guard<'hir> {
If(&'hir Expr<'hir>),
// FIXME use ExprKind::Let for this.
IfLet(&'hir Pat<'hir>, &'hir Expr<'hir>),
}