@@ -609,30 +609,40 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
609609 let location = self . get_caller_location ( bx, terminator. source_info ) . immediate ( ) ;
610610
611611 // Put together the arguments to the panic entry point.
612- let ( lang_item, args) = match msg {
612+ let ( lang_item, args, generic ) = match msg {
613613 AssertKind :: BoundsCheck { ref len, ref index } => {
614614 let len = self . codegen_operand ( bx, len) . immediate ( ) ;
615615 let index = self . codegen_operand ( bx, index) . immediate ( ) ;
616616 // It's `fn panic_bounds_check(index: usize, len: usize)`,
617617 // and `#[track_caller]` adds an implicit third argument.
618- ( LangItem :: PanicBoundsCheck , vec ! [ index, len, location] )
618+ ( LangItem :: PanicBoundsCheck , vec ! [ index, len, location] , None )
619619 }
620620 AssertKind :: MisalignedPointerDereference { ref required, ref found } => {
621621 let required = self . codegen_operand ( bx, required) . immediate ( ) ;
622622 let found = self . codegen_operand ( bx, found) . immediate ( ) ;
623623 // It's `fn panic_misaligned_pointer_dereference(required: usize, found: usize)`,
624624 // and `#[track_caller]` adds an implicit third argument.
625- ( LangItem :: PanicMisalignedPointerDereference , vec ! [ required, found, location] )
625+ ( LangItem :: PanicMisalignedPointerDereference , vec ! [ required, found, location] , None )
626+ }
627+ AssertKind :: OccupiedNiche { ref found, ref start, ref end } => {
628+ let found = self . codegen_operand ( bx, found) ;
629+ let generic_arg = ty:: GenericArg :: from ( found. layout . ty ) ;
630+ let found = found. immediate ( ) ;
631+ let start = self . codegen_operand ( bx, start) . immediate ( ) ;
632+ let end = self . codegen_operand ( bx, end) . immediate ( ) ;
633+ // It's `fn panic_occupied_niche<T>(found: T, start: T, end: T)`,
634+ // and `#[track_caller]` adds an implicit fourth argument.
635+ ( LangItem :: PanicOccupiedNiche , vec ! [ found, start, end, location] , Some ( generic_arg) )
626636 }
627637 _ => {
628638 let msg = bx. const_str ( msg. description ( ) ) ;
629639 // It's `pub fn panic(expr: &str)`, with the wide reference being passed
630640 // as two arguments, and `#[track_caller]` adds an implicit third argument.
631- ( LangItem :: Panic , vec ! [ msg. 0 , msg. 1 , location] )
641+ ( LangItem :: Panic , vec ! [ msg. 0 , msg. 1 , location] , None )
632642 }
633643 } ;
634644
635- let ( fn_abi, llfn) = common:: build_langcall ( bx, Some ( span) , lang_item) ;
645+ let ( fn_abi, llfn) = common:: build_langcall ( bx, Some ( span) , lang_item, generic ) ;
636646
637647 // Codegen the actual panic invoke/call.
638648 let merging_succ = helper. do_call ( self , bx, fn_abi, llfn, & args, None , unwind, & [ ] , false ) ;
@@ -651,7 +661,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
651661 self . set_debug_loc ( bx, terminator. source_info ) ;
652662
653663 // Obtain the panic entry point.
654- let ( fn_abi, llfn) = common:: build_langcall ( bx, Some ( span) , reason. lang_item ( ) ) ;
664+ let ( fn_abi, llfn) = common:: build_langcall ( bx, Some ( span) , reason. lang_item ( ) , None ) ;
655665
656666 // Codegen the actual panic invoke/call.
657667 let merging_succ = helper. do_call (
@@ -712,8 +722,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
712722 let msg = bx. const_str ( & msg_str) ;
713723
714724 // Obtain the panic entry point.
715- let ( fn_abi, llfn) =
716- common:: build_langcall ( bx, Some ( source_info. span ) , LangItem :: PanicNounwind ) ;
725+ let ( fn_abi, llfn) = common:: build_langcall (
726+ bx,
727+ Some ( source_info. span ) ,
728+ LangItem :: PanicNounwind ,
729+ None ,
730+ ) ;
717731
718732 // Codegen the actual panic invoke/call.
719733 helper. do_call (
@@ -1622,7 +1636,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
16221636
16231637 self . set_debug_loc ( & mut bx, mir:: SourceInfo :: outermost ( self . mir . span ) ) ;
16241638
1625- let ( fn_abi, fn_ptr) = common:: build_langcall ( & bx, None , reason. lang_item ( ) ) ;
1639+ let ( fn_abi, fn_ptr) = common:: build_langcall ( & bx, None , reason. lang_item ( ) , None ) ;
16261640 let fn_ty = bx. fn_decl_backend_type ( & fn_abi) ;
16271641
16281642 let llret = bx. call ( fn_ty, None , Some ( & fn_abi) , fn_ptr, & [ ] , funclet. as_ref ( ) ) ;
0 commit comments