@@ -14,7 +14,7 @@ use rustc_middle::middle::region;
14
14
use rustc_middle:: mir:: { self , * } ;
15
15
use rustc_middle:: thir:: { self , * } ;
16
16
use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty } ;
17
- use rustc_span:: { BytePos , Pos , Span , Symbol } ;
17
+ use rustc_span:: { BytePos , Pos , Span , Symbol , sym } ;
18
18
use tracing:: { debug, instrument} ;
19
19
20
20
use crate :: builder:: ForGuard :: { self , OutsideGuard , RefWithinGuard } ;
@@ -458,7 +458,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
458
458
opt_scrutinee_place,
459
459
) ;
460
460
461
- let arm_block = this. bind_pattern (
461
+ let mut arm_block = this. bind_pattern (
462
462
outer_source_info,
463
463
branch,
464
464
& built_match_tree. fake_borrow_temps ,
@@ -467,6 +467,34 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
467
467
EmitStorageLive :: Yes ,
468
468
) ;
469
469
470
+ if arm. is_cold
471
+ && let Some ( cold_path_def) = this. tcx . get_diagnostic_item ( sym:: cold_path)
472
+ {
473
+ let cold_path_ty = this. tcx . type_of ( cold_path_def) . instantiate_identity ( ) ;
474
+ let cold_path = Operand :: Constant ( Box :: new ( ConstOperand {
475
+ span : arm. span ,
476
+ user_ty : None ,
477
+ const_ : Const :: from_value ( ConstValue :: ZeroSized , cold_path_ty) ,
478
+ } ) ) ;
479
+ let new_arm_block = this. cfg . start_new_block ( ) ;
480
+ let cold_path_result =
481
+ this. local_decls . push ( LocalDecl :: new ( this. tcx . types . unit , arm. span ) ) ;
482
+ this. cfg . terminate (
483
+ arm_block,
484
+ this. source_info ( arm. span ) ,
485
+ TerminatorKind :: Call {
486
+ func : cold_path,
487
+ args : Box :: new ( [ ] ) ,
488
+ destination : Place :: from ( cold_path_result) ,
489
+ target : Some ( new_arm_block) ,
490
+ unwind : UnwindAction :: Unreachable ,
491
+ call_source : CallSource :: Misc ,
492
+ fn_span : arm. span ,
493
+ } ,
494
+ ) ;
495
+ arm_block = new_arm_block;
496
+ }
497
+
470
498
this. fixed_temps_scope = old_dedup_scope;
471
499
472
500
if let Some ( source_scope) = scope {
0 commit comments