@@ -369,7 +369,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
369369 let arm = & self . thir [ arm] ;
370370 let has_match_guard =
371371 if arm. guard . is_some ( ) { HasMatchGuard :: Yes } else { HasMatchGuard :: No } ;
372- ( & * arm. pattern , has_match_guard)
372+ ( & * arm. pattern , has_match_guard, arm . is_cold )
373373 } )
374374 . collect ( ) ;
375375 let built_tree = self . lower_match_tree (
@@ -467,6 +467,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
467467 EmitStorageLive :: Yes ,
468468 ) ;
469469
470+ // TODO - make arm_block cold
471+
470472 this. fixed_temps_scope = old_dedup_scope;
471473
472474 if let Some ( source_scope) = scope {
@@ -676,7 +678,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
676678 irrefutable_pat. span ,
677679 & initializer,
678680 irrefutable_pat. span ,
679- vec ! [ ( irrefutable_pat, HasMatchGuard :: No ) ] ,
681+ vec ! [ ( irrefutable_pat, HasMatchGuard :: No , false ) ] ,
680682 false ,
681683 ) ;
682684 let [ branch] = built_tree. branches . try_into ( ) . unwrap ( ) ;
@@ -1072,6 +1074,9 @@ struct Candidate<'tcx> {
10721074 /// whether the enclosing match arm has a guard.
10731075 has_guard : bool ,
10741076
1077+ /// Whether this 'Candidate' comes from a cold arm.
1078+ is_cold : bool ,
1079+
10751080 /// Holds extra pattern data that was prepared by [`FlatPat`], including bindings and
10761081 /// ascriptions that must be established if this candidate succeeds.
10771082 extra_data : PatternExtraData < ' tcx > ,
@@ -1103,22 +1108,25 @@ impl<'tcx> Candidate<'tcx> {
11031108 place : PlaceBuilder < ' tcx > ,
11041109 pattern : & Pat < ' tcx > ,
11051110 has_guard : HasMatchGuard ,
1111+ is_cold : bool ,
11061112 cx : & mut Builder < ' _ , ' tcx > ,
11071113 ) -> Self {
11081114 // Use `FlatPat` to build simplified match pairs, then immediately
11091115 // incorporate them into a new candidate.
11101116 Self :: from_flat_pat (
11111117 FlatPat :: new ( place, pattern, cx) ,
11121118 matches ! ( has_guard, HasMatchGuard :: Yes ) ,
1119+ is_cold,
11131120 )
11141121 }
11151122
11161123 /// Incorporates an already-simplified [`FlatPat`] into a new candidate.
1117- fn from_flat_pat ( flat_pat : FlatPat < ' tcx > , has_guard : bool ) -> Self {
1124+ fn from_flat_pat ( flat_pat : FlatPat < ' tcx > , has_guard : bool , is_cold : bool ) -> Self {
11181125 Candidate {
11191126 match_pairs : flat_pat. match_pairs ,
11201127 extra_data : flat_pat. extra_data ,
11211128 has_guard,
1129+ is_cold,
11221130 subcandidates : Vec :: new ( ) ,
11231131 or_span : None ,
11241132 otherwise_block : None ,
@@ -1484,7 +1492,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14841492 scrutinee_span : Span ,
14851493 scrutinee_place_builder : & PlaceBuilder < ' tcx > ,
14861494 match_start_span : Span ,
1487- patterns : Vec < ( & Pat < ' tcx > , HasMatchGuard ) > ,
1495+ patterns : Vec < ( & Pat < ' tcx > , HasMatchGuard , bool ) > ,
14881496 refutable : bool ,
14891497 ) -> BuiltMatchTree < ' tcx > {
14901498 // Assemble the initial list of candidates. These top-level candidates are 1:1 with the
@@ -1493,8 +1501,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14931501 // match arms directly.
14941502 let mut candidates: Vec < Candidate < ' _ > > = patterns
14951503 . into_iter ( )
1496- . map ( |( pat, has_guard) | {
1497- Candidate :: new ( scrutinee_place_builder. clone ( ) , pat, has_guard, self )
1504+ . map ( |( pat, has_guard, is_cold ) | {
1505+ Candidate :: new ( scrutinee_place_builder. clone ( ) , pat, has_guard, is_cold , self )
14981506 } )
14991507 . collect ( ) ;
15001508
@@ -1866,7 +1874,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18661874 candidate. subcandidates = pats
18671875 . into_vec ( )
18681876 . into_iter ( )
1869- . map ( |flat_pat| Candidate :: from_flat_pat ( flat_pat, candidate. has_guard ) )
1877+ . map ( |flat_pat| {
1878+ Candidate :: from_flat_pat ( flat_pat, candidate. has_guard , candidate. is_cold )
1879+ } )
18701880 . collect ( ) ;
18711881 candidate. subcandidates [ 0 ] . false_edge_start_block = candidate. false_edge_start_block ;
18721882 }
@@ -2346,7 +2356,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
23462356 expr_span,
23472357 & scrutinee,
23482358 pat. span ,
2349- vec ! [ ( pat, HasMatchGuard :: No ) ] ,
2359+ vec ! [ ( pat, HasMatchGuard :: No , false ) ] ,
23502360 true ,
23512361 ) ;
23522362 let [ branch] = built_tree. branches . try_into ( ) . unwrap ( ) ;
0 commit comments