@@ -19,7 +19,7 @@ use rustc_middle::middle::region;
19
19
use rustc_middle:: mir:: * ;
20
20
use rustc_middle:: thir:: { self , * } ;
21
21
use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty } ;
22
- use rustc_span:: symbol:: Symbol ;
22
+ use rustc_span:: symbol:: { sym , Symbol } ;
23
23
use rustc_span:: { BytePos , Pos , Span } ;
24
24
use rustc_target:: abi:: VariantIdx ;
25
25
use smallvec:: { smallvec, SmallVec } ;
@@ -292,8 +292,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
292
292
. map ( |arm| {
293
293
let arm = & self . thir [ arm] ;
294
294
let arm_has_guard = arm. guard . is_some ( ) ;
295
- let arm_candidate =
296
- Candidate :: new ( scrutinee. clone ( ) , & arm. pattern , arm_has_guard, self ) ;
295
+ let arm_is_cold = arm. is_cold ;
296
+ let arm_candidate = Candidate :: new (
297
+ scrutinee. clone ( ) ,
298
+ & arm. pattern ,
299
+ arm_has_guard,
300
+ arm_is_cold,
301
+ self ,
302
+ ) ;
297
303
( arm, arm_candidate)
298
304
} )
299
305
. collect ( )
@@ -444,6 +450,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
444
450
false ,
445
451
) ;
446
452
453
+ // TODO - make arm_block cold
454
+
447
455
this. fixed_temps_scope = old_dedup_scope;
448
456
449
457
if let Some ( source_scope) = scope {
@@ -652,7 +660,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
652
660
initializer : PlaceBuilder < ' tcx > ,
653
661
set_match_place : bool ,
654
662
) -> BlockAnd < ( ) > {
655
- let mut candidate = Candidate :: new ( initializer. clone ( ) , irrefutable_pat, false , self ) ;
663
+ let mut candidate =
664
+ Candidate :: new ( initializer. clone ( ) , irrefutable_pat, false , false , self ) ;
656
665
let fake_borrow_temps = self . lower_match_tree (
657
666
block,
658
667
irrefutable_pat. span ,
@@ -950,6 +959,9 @@ struct Candidate<'pat, 'tcx> {
950
959
/// Whether this `Candidate` has a guard.
951
960
has_guard : bool ,
952
961
962
+ /// Whether this 'Candidate' comes from a cold arm.
963
+ is_cold : bool ,
964
+
953
965
/// All of these must be satisfied...
954
966
match_pairs : SmallVec < [ MatchPair < ' pat , ' tcx > ; 1 ] > ,
955
967
@@ -976,11 +988,13 @@ impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
976
988
place : PlaceBuilder < ' tcx > ,
977
989
pattern : & ' pat Pat < ' tcx > ,
978
990
has_guard : bool ,
991
+ is_cold : bool ,
979
992
cx : & Builder < ' _ , ' tcx > ,
980
993
) -> Self {
981
994
Candidate {
982
995
span : pattern. span ,
983
996
has_guard,
997
+ is_cold,
984
998
match_pairs : smallvec ! [ MatchPair :: new( place, pattern, cx) ] ,
985
999
bindings : Vec :: new ( ) ,
986
1000
ascriptions : Vec :: new ( ) ,
@@ -1500,7 +1514,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1500
1514
debug ! ( "candidate={:#?}\n pats={:#?}" , candidate, pats) ;
1501
1515
let mut or_candidates: Vec < _ > = pats
1502
1516
. iter ( )
1503
- . map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard , self ) )
1517
+ . map ( |pat| {
1518
+ Candidate :: new ( place. clone ( ) , pat, candidate. has_guard , candidate. is_cold , self )
1519
+ } )
1504
1520
. collect ( ) ;
1505
1521
let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
1506
1522
let otherwise = if candidate. otherwise_block . is_some ( ) {
@@ -1890,9 +1906,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1890
1906
let expr_span = self . thir [ expr_id] . span ;
1891
1907
let expr_place_builder = unpack ! ( block = self . lower_scrutinee( block, expr_id, expr_span) ) ;
1892
1908
let wildcard = Pat :: wildcard_from_ty ( pat. ty ) ;
1893
- let mut guard_candidate = Candidate :: new ( expr_place_builder. clone ( ) , pat, false , self ) ;
1909
+ let mut guard_candidate =
1910
+ Candidate :: new ( expr_place_builder. clone ( ) , pat, false , false , self ) ;
1894
1911
let mut otherwise_candidate =
1895
- Candidate :: new ( expr_place_builder. clone ( ) , & wildcard, false , self ) ;
1912
+ Candidate :: new ( expr_place_builder. clone ( ) , & wildcard, false , false , self ) ;
1896
1913
let fake_borrow_temps = self . lower_match_tree (
1897
1914
block,
1898
1915
pat. span ,
@@ -2386,8 +2403,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2386
2403
let ( matching, failure) = self . in_if_then_scope ( * let_else_scope, else_block_span, |this| {
2387
2404
let scrutinee = unpack ! ( block = this. lower_scrutinee( block, init_id, initializer_span) ) ;
2388
2405
let pat = Pat { ty : pattern. ty , span : else_block_span, kind : PatKind :: Wild } ;
2389
- let mut wildcard = Candidate :: new ( scrutinee. clone ( ) , & pat, false , this) ;
2390
- let mut candidate = Candidate :: new ( scrutinee. clone ( ) , pattern, false , this) ;
2406
+ let mut wildcard = Candidate :: new ( scrutinee. clone ( ) , & pat, false , false , this) ;
2407
+ let mut candidate = Candidate :: new ( scrutinee. clone ( ) , pattern, false , false , this) ;
2391
2408
let fake_borrow_temps = this. lower_match_tree (
2392
2409
block,
2393
2410
initializer_span,
0 commit comments