@@ -651,10 +651,26 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
651
651
( LangItem :: PanicMisalignedPointerDereference , vec ! [ required, found, location] )
652
652
}
653
653
_ => {
654
- let msg = bx. const_str ( msg. description ( ) ) ;
655
- // It's `pub fn panic(expr: &str)`, with the wide reference being passed
656
- // as two arguments, and `#[track_caller]` adds an implicit third argument.
657
- ( LangItem :: Panic , vec ! [ msg. 0 , msg. 1 , location] )
654
+ // It's `pub fn panic<const M: &str>()` and `#[track_caller]` adds an implicit argument.
655
+ //
656
+ // Effects add an implicit `const host: bool` so we add that in as well, matching
657
+ // behavior from `ty::Instance::mono`.
658
+
659
+ let tcx = bx. tcx ( ) ;
660
+ let def_id = tcx. require_lang_item ( LangItem :: PanicConst , Some ( span) ) ;
661
+
662
+ let val_tree = ty:: ValTree :: from_raw_bytes ( tcx, msg. description ( ) . as_bytes ( ) ) ;
663
+ let desc = ty:: Const :: new_value ( tcx, val_tree, Ty :: new_static_str ( tcx) ) ;
664
+ let args = tcx. mk_args ( & [ ty:: GenericArg :: from ( desc) , tcx. consts . true_ . into ( ) ] ) ;
665
+ let instance = ty:: Instance :: new ( def_id, args) ;
666
+ let ( fn_abi, llfn) =
667
+ ( bx. fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) , bx. get_fn_addr ( instance) ) ;
668
+
669
+ // Codegen the actual panic invoke/call.
670
+ let merging_succ =
671
+ helper. do_call ( self , bx, fn_abi, llfn, & [ location] , None , unwind, & [ ] , false ) ;
672
+ assert_eq ! ( merging_succ, MergingSucc :: False ) ;
673
+ return MergingSucc :: False ;
658
674
}
659
675
} ;
660
676
0 commit comments