@@ -371,7 +371,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
371371 let expr_exit = self . add_ast_node ( id, & [ ] ) ;
372372
373373 // Keep track of the previous guard expressions
374- let mut prev_guards = Vec :: new ( ) ;
374+ let mut prev_guard = None ;
375+ let match_scope = region:: Scope { id, data : region:: ScopeData :: Node } ;
375376
376377 for arm in arms {
377378 // Add an exit node for when we've visited all the
@@ -389,23 +390,23 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
389390 let guard_start = self . add_dummy_node ( & [ pat_exit] ) ;
390391 // Visit the guard expression
391392 let guard_exit = match guard {
392- hir:: Guard :: If ( ref e) => self . expr ( e, guard_start) ,
393+ hir:: Guard :: If ( ref e) => ( & * * e , self . expr ( e, guard_start) ) ,
393394 } ;
394395 // #47295: We used to have very special case code
395396 // here for when a pair of arms are both formed
396397 // solely from constants, and if so, not add these
397398 // edges. But this was not actually sound without
398399 // other constraints that we stopped enforcing at
399400 // some point.
400- while let Some ( prev ) = prev_guards . pop ( ) {
401- self . add_contained_edge ( prev , guard_start) ;
401+ if let Some ( ( prev_guard , prev_index ) ) = prev_guard . take ( ) {
402+ self . add_exiting_edge ( prev_guard , prev_index , match_scope , guard_start) ;
402403 }
403404
404405 // Push the guard onto the list of previous guards
405- prev_guards . push ( guard_exit) ;
406+ prev_guard = Some ( guard_exit) ;
406407
407408 // Update the exit node for the pattern
408- pat_exit = guard_exit;
409+ pat_exit = guard_exit. 1 ;
409410 }
410411
411412 // Add an edge from the exit of this pattern to the
0 commit comments