@@ -63,6 +63,9 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
6363 yield_data. expr_and_pat_count, self . expr_count, source_span
6464 ) ;
6565
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.
6669 if guard_borrowing_from_pattern
6770 || yield_data. expr_and_pat_count >= self . expr_count
6871 {
@@ -225,11 +228,9 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
225228 }
226229
227230 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 {
233234 self . guard_bindings . push ( <_ >:: default ( ) ) ;
234235 ArmPatCollector {
235236 guard_bindings_set : & mut self . guard_bindings_set ,
@@ -238,7 +239,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
238239 . last_mut ( )
239240 . expect ( "should have pushed at least one earlier" ) ,
240241 }
241- . visit_pat ( & arm . pat ) ;
242+ . visit_pat ( pat) ;
242243
243244 match g {
244245 Guard :: If ( ref e) => {
@@ -255,7 +256,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
255256 ) ;
256257 }
257258 }
258- self . visit_expr ( & arm . body ) ;
259+ self . visit_expr ( body) ;
259260 }
260261
261262 fn visit_pat ( & mut self , pat : & ' tcx Pat < ' tcx > ) {
0 commit comments