@@ -609,30 +609,40 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
609
609
let location = self . get_caller_location ( bx, terminator. source_info ) . immediate ( ) ;
610
610
611
611
// Put together the arguments to the panic entry point.
612
- let ( lang_item, args) = match msg {
612
+ let ( lang_item, args, generic ) = match msg {
613
613
AssertKind :: BoundsCheck { ref len, ref index } => {
614
614
let len = self . codegen_operand ( bx, len) . immediate ( ) ;
615
615
let index = self . codegen_operand ( bx, index) . immediate ( ) ;
616
616
// It's `fn panic_bounds_check(index: usize, len: usize)`,
617
617
// and `#[track_caller]` adds an implicit third argument.
618
- ( LangItem :: PanicBoundsCheck , vec ! [ index, len, location] )
618
+ ( LangItem :: PanicBoundsCheck , vec ! [ index, len, location] , None )
619
619
}
620
620
AssertKind :: MisalignedPointerDereference { ref required, ref found } => {
621
621
let required = self . codegen_operand ( bx, required) . immediate ( ) ;
622
622
let found = self . codegen_operand ( bx, found) . immediate ( ) ;
623
623
// It's `fn panic_misaligned_pointer_dereference(required: usize, found: usize)`,
624
624
// 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) )
626
636
}
627
637
_ => {
628
638
let msg = bx. const_str ( msg. description ( ) ) ;
629
639
// It's `pub fn panic(expr: &str)`, with the wide reference being passed
630
640
// 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 )
632
642
}
633
643
} ;
634
644
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 ) ;
636
646
637
647
// Codegen the actual panic invoke/call.
638
648
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> {
651
661
self . set_debug_loc ( bx, terminator. source_info ) ;
652
662
653
663
// 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 ) ;
655
665
656
666
// Codegen the actual panic invoke/call.
657
667
let merging_succ = helper. do_call (
@@ -712,8 +722,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
712
722
let msg = bx. const_str ( & msg_str) ;
713
723
714
724
// 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
+ ) ;
717
731
718
732
// Codegen the actual panic invoke/call.
719
733
helper. do_call (
@@ -1622,7 +1636,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1622
1636
1623
1637
self . set_debug_loc ( & mut bx, mir:: SourceInfo :: outermost ( self . mir . span ) ) ;
1624
1638
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 ) ;
1626
1640
let fn_ty = bx. fn_decl_backend_type ( & fn_abi) ;
1627
1641
1628
1642
let llret = bx. call ( fn_ty, None , Some ( & fn_abi) , fn_ptr, & [ ] , funclet. as_ref ( ) ) ;
0 commit comments