@@ -63,6 +63,9 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
63
63
yield_data. expr_and_pat_count, self . expr_count, source_span
64
64
) ;
65
65
66
+ // If it is a borrowing happening in the guard,
67
+ // it needs to be recorded regardless because they
68
+ // do live across this yield point.
66
69
if guard_borrowing_from_pattern
67
70
|| yield_data. expr_and_pat_count >= self . expr_count
68
71
{
@@ -225,11 +228,9 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
225
228
}
226
229
227
230
fn visit_arm ( & mut self , arm : & ' tcx Arm < ' tcx > ) {
228
- if arm. guard . is_some ( ) {
229
- self . guard_bindings . push ( <_ >:: default ( ) ) ;
230
- }
231
- self . visit_pat ( & arm. pat ) ;
232
- if let Some ( ref g) = arm. guard {
231
+ let Arm { guard, pat, body, .. } = arm;
232
+ self . visit_pat ( pat) ;
233
+ if let Some ( ref g) = guard {
233
234
self . guard_bindings . push ( <_ >:: default ( ) ) ;
234
235
ArmPatCollector {
235
236
guard_bindings_set : & mut self . guard_bindings_set ,
@@ -238,7 +239,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
238
239
. last_mut ( )
239
240
. expect ( "should have pushed at least one earlier" ) ,
240
241
}
241
- . visit_pat ( & arm . pat ) ;
242
+ . visit_pat ( pat) ;
242
243
243
244
match g {
244
245
Guard :: If ( ref e) => {
@@ -255,7 +256,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
255
256
) ;
256
257
}
257
258
}
258
- self . visit_expr ( & arm . body ) ;
259
+ self . visit_expr ( body) ;
259
260
}
260
261
261
262
fn visit_pat ( & mut self , pat : & ' tcx Pat < ' tcx > ) {
0 commit comments