@@ -19,7 +19,7 @@ use rustc_middle::middle::region;
1919use rustc_middle:: mir:: * ;
2020use rustc_middle:: thir:: { self , * } ;
2121use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty } ;
22- use rustc_span:: symbol:: Symbol ;
22+ use rustc_span:: symbol:: { sym , Symbol } ;
2323use rustc_span:: { BytePos , Pos , Span } ;
2424use rustc_target:: abi:: VariantIdx ;
2525use smallvec:: { smallvec, SmallVec } ;
@@ -292,8 +292,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
292292 . map ( |arm| {
293293 let arm = & self . thir [ arm] ;
294294 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+ ) ;
297303 ( arm, arm_candidate)
298304 } )
299305 . collect ( )
@@ -444,6 +450,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
444450 false ,
445451 ) ;
446452
453+ // TODO - make arm_block cold
454+
447455 this. fixed_temps_scope = old_dedup_scope;
448456
449457 if let Some ( source_scope) = scope {
@@ -652,7 +660,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
652660 initializer : PlaceBuilder < ' tcx > ,
653661 set_match_place : bool ,
654662 ) -> 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 ) ;
656665 let fake_borrow_temps = self . lower_match_tree (
657666 block,
658667 irrefutable_pat. span ,
@@ -950,6 +959,9 @@ struct Candidate<'pat, 'tcx> {
950959 /// Whether this `Candidate` has a guard.
951960 has_guard : bool ,
952961
962+ /// Whether this 'Candidate' comes from a cold arm.
963+ is_cold : bool ,
964+
953965 /// All of these must be satisfied...
954966 match_pairs : SmallVec < [ MatchPair < ' pat , ' tcx > ; 1 ] > ,
955967
@@ -976,11 +988,13 @@ impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
976988 place : PlaceBuilder < ' tcx > ,
977989 pattern : & ' pat Pat < ' tcx > ,
978990 has_guard : bool ,
991+ is_cold : bool ,
979992 cx : & Builder < ' _ , ' tcx > ,
980993 ) -> Self {
981994 Candidate {
982995 span : pattern. span ,
983996 has_guard,
997+ is_cold,
984998 match_pairs : smallvec ! [ MatchPair :: new( place, pattern, cx) ] ,
985999 bindings : Vec :: new ( ) ,
9861000 ascriptions : Vec :: new ( ) ,
@@ -1500,7 +1514,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
15001514 debug ! ( "candidate={:#?}\n pats={:#?}" , candidate, pats) ;
15011515 let mut or_candidates: Vec < _ > = pats
15021516 . 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+ } )
15041520 . collect ( ) ;
15051521 let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
15061522 let otherwise = if candidate. otherwise_block . is_some ( ) {
@@ -1890,9 +1906,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18901906 let expr_span = self . thir [ expr_id] . span ;
18911907 let expr_place_builder = unpack ! ( block = self . lower_scrutinee( block, expr_id, expr_span) ) ;
18921908 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 ) ;
18941911 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 ) ;
18961913 let fake_borrow_temps = self . lower_match_tree (
18971914 block,
18981915 pat. span ,
@@ -2386,8 +2403,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
23862403 let ( matching, failure) = self . in_if_then_scope ( * let_else_scope, else_block_span, |this| {
23872404 let scrutinee = unpack ! ( block = this. lower_scrutinee( block, init_id, initializer_span) ) ;
23882405 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) ;
23912408 let fake_borrow_temps = this. lower_match_tree (
23922409 block,
23932410 initializer_span,
0 commit comments