Rollup merge of #115999 - matthewjasper:closure-capture-let-guards, r=b-naber
Capture scrutinee of if let guards correctly Previously we were always capturing by value. cc #51114
This commit is contained in:
commit
e6f4b35d9f
5 changed files with 164 additions and 4 deletions
|
@ -664,10 +664,12 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
);
|
||||
self.walk_pat(discr_place, arm.pat, arm.guard.is_some());
|
||||
|
||||
if let Some(hir::Guard::If(e)) = arm.guard {
|
||||
self.consume_expr(e)
|
||||
} else if let Some(hir::Guard::IfLet(ref l)) = arm.guard {
|
||||
self.consume_expr(l.init)
|
||||
match arm.guard {
|
||||
Some(hir::Guard::If(ref e)) => self.consume_expr(e),
|
||||
Some(hir::Guard::IfLet(ref l)) => {
|
||||
self.walk_local(l.init, l.pat, None, |t| t.borrow_expr(l.init, ty::ImmBorrow))
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
self.consume_expr(arm.body);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue