@@ -369,7 +369,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
369
369
let arm = & self . thir [ arm] ;
370
370
let has_match_guard =
371
371
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 )
373
373
} )
374
374
. collect ( ) ;
375
375
let built_tree = self . lower_match_tree (
@@ -467,6 +467,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
467
467
EmitStorageLive :: Yes ,
468
468
) ;
469
469
470
+ // TODO - make arm_block cold
471
+
470
472
this. fixed_temps_scope = old_dedup_scope;
471
473
472
474
if let Some ( source_scope) = scope {
@@ -676,7 +678,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
676
678
irrefutable_pat. span ,
677
679
& initializer,
678
680
irrefutable_pat. span ,
679
- vec ! [ ( irrefutable_pat, HasMatchGuard :: No ) ] ,
681
+ vec ! [ ( irrefutable_pat, HasMatchGuard :: No , false ) ] ,
680
682
false ,
681
683
) ;
682
684
let [ branch] = built_tree. branches . try_into ( ) . unwrap ( ) ;
@@ -1072,6 +1074,9 @@ struct Candidate<'tcx> {
1072
1074
/// whether the enclosing match arm has a guard.
1073
1075
has_guard : bool ,
1074
1076
1077
+ /// Whether this 'Candidate' comes from a cold arm.
1078
+ is_cold : bool ,
1079
+
1075
1080
/// Holds extra pattern data that was prepared by [`FlatPat`], including bindings and
1076
1081
/// ascriptions that must be established if this candidate succeeds.
1077
1082
extra_data : PatternExtraData < ' tcx > ,
@@ -1103,22 +1108,25 @@ impl<'tcx> Candidate<'tcx> {
1103
1108
place : PlaceBuilder < ' tcx > ,
1104
1109
pattern : & Pat < ' tcx > ,
1105
1110
has_guard : HasMatchGuard ,
1111
+ is_cold : bool ,
1106
1112
cx : & mut Builder < ' _ , ' tcx > ,
1107
1113
) -> Self {
1108
1114
// Use `FlatPat` to build simplified match pairs, then immediately
1109
1115
// incorporate them into a new candidate.
1110
1116
Self :: from_flat_pat (
1111
1117
FlatPat :: new ( place, pattern, cx) ,
1112
1118
matches ! ( has_guard, HasMatchGuard :: Yes ) ,
1119
+ is_cold,
1113
1120
)
1114
1121
}
1115
1122
1116
1123
/// 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 {
1118
1125
Candidate {
1119
1126
match_pairs : flat_pat. match_pairs ,
1120
1127
extra_data : flat_pat. extra_data ,
1121
1128
has_guard,
1129
+ is_cold,
1122
1130
subcandidates : Vec :: new ( ) ,
1123
1131
or_span : None ,
1124
1132
otherwise_block : None ,
@@ -1484,7 +1492,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1484
1492
scrutinee_span : Span ,
1485
1493
scrutinee_place_builder : & PlaceBuilder < ' tcx > ,
1486
1494
match_start_span : Span ,
1487
- patterns : Vec < ( & Pat < ' tcx > , HasMatchGuard ) > ,
1495
+ patterns : Vec < ( & Pat < ' tcx > , HasMatchGuard , bool ) > ,
1488
1496
refutable : bool ,
1489
1497
) -> BuiltMatchTree < ' tcx > {
1490
1498
// 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> {
1493
1501
// match arms directly.
1494
1502
let mut candidates: Vec < Candidate < ' _ > > = patterns
1495
1503
. 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 )
1498
1506
} )
1499
1507
. collect ( ) ;
1500
1508
@@ -1866,7 +1874,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1866
1874
candidate. subcandidates = pats
1867
1875
. into_vec ( )
1868
1876
. 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
+ } )
1870
1880
. collect ( ) ;
1871
1881
candidate. subcandidates [ 0 ] . false_edge_start_block = candidate. false_edge_start_block ;
1872
1882
}
@@ -2346,7 +2356,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2346
2356
expr_span,
2347
2357
& scrutinee,
2348
2358
pat. span ,
2349
- vec ! [ ( pat, HasMatchGuard :: No ) ] ,
2359
+ vec ! [ ( pat, HasMatchGuard :: No , false ) ] ,
2350
2360
true ,
2351
2361
) ;
2352
2362
let [ branch] = built_tree. branches . try_into ( ) . unwrap ( ) ;
0 commit comments