@@ -14,7 +14,7 @@ use rustc_middle::middle::region;
1414use rustc_middle:: mir:: { self , * } ;
1515use rustc_middle:: thir:: { self , * } ;
1616use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty } ;
17- use rustc_span:: { BytePos , Pos , Span , Symbol } ;
17+ use rustc_span:: { BytePos , Pos , Span , Symbol , sym } ;
1818use tracing:: { debug, instrument} ;
1919
2020use crate :: builder:: ForGuard :: { self , OutsideGuard , RefWithinGuard } ;
@@ -458,7 +458,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
458458 opt_scrutinee_place,
459459 ) ;
460460
461- let arm_block = this. bind_pattern (
461+ let mut arm_block = this. bind_pattern (
462462 outer_source_info,
463463 branch,
464464 & built_match_tree. fake_borrow_temps ,
@@ -467,6 +467,34 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
467467 EmitStorageLive :: Yes ,
468468 ) ;
469469
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+
470498 this. fixed_temps_scope = old_dedup_scope;
471499
472500 if let Some ( source_scope) = scope {
0 commit comments