@@ -364,12 +364,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
364364 let arm_block = this. bind_pattern (
365365 outer_source_info,
366366 candidate,
367- arm. guard . as_ref ( ) ,
368367 & fake_borrow_temps,
369368 scrutinee_span,
370- Some ( arm. span ) ,
371- Some ( arm. scope ) ,
372- Some ( match_scope) ,
369+ Some ( ( arm, match_scope) ) ,
373370 false ,
374371 ) ;
375372
@@ -410,12 +407,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
410407 & mut self ,
411408 outer_source_info : SourceInfo ,
412409 candidate : Candidate < ' _ , ' tcx > ,
413- guard : Option < & Guard < ' tcx > > ,
414410 fake_borrow_temps : & [ ( Place < ' tcx > , Local ) ] ,
415411 scrutinee_span : Span ,
416- arm_span : Option < Span > ,
417- arm_scope : Option < region:: Scope > ,
418- match_scope : Option < region:: Scope > ,
412+ arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
419413 storages_alive : bool ,
420414 ) -> BasicBlock {
421415 if candidate. subcandidates . is_empty ( ) {
@@ -424,11 +418,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
424418 self . bind_and_guard_matched_candidate (
425419 candidate,
426420 & [ ] ,
427- guard,
428421 fake_borrow_temps,
429422 scrutinee_span,
430- arm_span,
431- match_scope,
423+ arm_match_scope,
432424 true ,
433425 storages_alive,
434426 )
@@ -449,28 +441,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
449441 // we lower the guard.
450442 let target_block = self . cfg . start_new_block ( ) ;
451443 let mut schedule_drops = true ;
444+ let arm = arm_match_scope. unzip ( ) . 0 ;
452445 // We keep a stack of all of the bindings and type ascriptions
453446 // from the parent candidates that we visit, that also need to
454447 // be bound for each candidate.
455448 traverse_candidate (
456449 candidate,
457450 & mut Vec :: new ( ) ,
458451 & mut |leaf_candidate, parent_bindings| {
459- if let Some ( arm_scope ) = arm_scope {
460- self . clear_top_scope ( arm_scope ) ;
452+ if let Some ( arm ) = arm {
453+ self . clear_top_scope ( arm . scope ) ;
461454 }
462455 let binding_end = self . bind_and_guard_matched_candidate (
463456 leaf_candidate,
464457 parent_bindings,
465- guard,
466458 & fake_borrow_temps,
467459 scrutinee_span,
468- arm_span,
469- match_scope,
460+ arm_match_scope,
470461 schedule_drops,
471462 storages_alive,
472463 ) ;
473- if arm_scope . is_none ( ) {
464+ if arm . is_none ( ) {
474465 schedule_drops = false ;
475466 }
476467 self . cfg . goto ( binding_end, outer_source_info, target_block) ;
@@ -636,12 +627,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
636627 self . bind_pattern (
637628 self . source_info ( irrefutable_pat. span ) ,
638629 candidate,
639- None ,
640630 & fake_borrow_temps,
641631 irrefutable_pat. span ,
642632 None ,
643- None ,
644- None ,
645633 false ,
646634 )
647635 . unit ( )
@@ -1820,12 +1808,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18201808 let post_guard_block = self . bind_pattern (
18211809 self . source_info ( pat. span ) ,
18221810 guard_candidate,
1823- None ,
18241811 & fake_borrow_temps,
18251812 expr. span ,
18261813 None ,
1827- None ,
1828- None ,
18291814 false ,
18301815 ) ;
18311816
@@ -1844,11 +1829,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18441829 & mut self ,
18451830 candidate : Candidate < ' pat , ' tcx > ,
18461831 parent_bindings : & [ ( Vec < Binding < ' tcx > > , Vec < Ascription < ' tcx > > ) ] ,
1847- guard : Option < & Guard < ' tcx > > ,
18481832 fake_borrows : & [ ( Place < ' tcx > , Local ) ] ,
18491833 scrutinee_span : Span ,
1850- arm_span : Option < Span > ,
1851- match_scope : Option < region:: Scope > ,
1834+ arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
18521835 schedule_drops : bool ,
18531836 storages_alive : bool ,
18541837 ) -> BasicBlock {
@@ -1960,7 +1943,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
19601943 // the reference that we create for the arm.
19611944 // * So we eagerly create the reference for the arm and then take a
19621945 // reference to that.
1963- if let Some ( guard) = guard {
1946+ if let Some ( ( arm, match_scope) ) = arm_match_scope
1947+ && let Some ( guard) = & arm. guard
1948+ {
19641949 let tcx = self . tcx ;
19651950 let bindings = parent_bindings
19661951 . iter ( )
@@ -1981,8 +1966,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
19811966 self . cfg . push_assign ( block, scrutinee_source_info, Place :: from ( temp) , borrow) ;
19821967 }
19831968
1984- let arm_span = arm_span. unwrap ( ) ;
1985- let match_scope = match_scope. unwrap ( ) ;
19861969 let mut guard_span = rustc_span:: DUMMY_SP ;
19871970
19881971 let ( post_guard_block, otherwise_post_guard_block) =
@@ -1995,13 +1978,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
19951978 e,
19961979 None ,
19971980 match_scope,
1998- this. source_info ( arm_span ) ,
1981+ this. source_info ( arm . span ) ,
19991982 )
20001983 }
20011984 Guard :: IfLet ( ref pat, scrutinee) => {
20021985 let s = & this. thir [ scrutinee] ;
20031986 guard_span = s. span ;
2004- this. lower_let_expr ( block, s, pat, match_scope, None , arm_span )
1987+ this. lower_let_expr ( block, s, pat, match_scope, None , arm . span )
20051988 }
20061989 } ) ;
20071990
@@ -2317,24 +2300,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
23172300 let matching = this. bind_pattern (
23182301 this. source_info ( pattern. span ) ,
23192302 candidate,
2320- None ,
23212303 & fake_borrow_temps,
23222304 initializer_span,
23232305 None ,
2324- None ,
2325- None ,
23262306 true ,
23272307 ) ;
23282308 // This block is for the failure case
23292309 let failure = this. bind_pattern (
23302310 this. source_info ( else_block_span) ,
23312311 wildcard,
2332- None ,
23332312 & fake_borrow_temps,
23342313 initializer_span,
23352314 None ,
2336- None ,
2337- None ,
23382315 true ,
23392316 ) ;
23402317 this. break_for_else ( failure, * let_else_scope, this. source_info ( initializer_span) ) ;
0 commit comments