@@ -15,7 +15,7 @@ use crate::traits::*;
1515
1616use std:: borrow:: Cow ;
1717
18- use syntax:: symbol:: Symbol ;
18+ use syntax:: { source_map :: Span , symbol:: Symbol } ;
1919
2020use super :: { FunctionCx , LocalRef } ;
2121use super :: place:: PlaceRef ;
@@ -420,8 +420,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
420420 self . set_debug_loc ( & mut bx, terminator. source_info ) ;
421421
422422 // Get the location information.
423- let loc = bx. sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
424- let location = bx. static_panic_location ( & loc) ;
423+ let location = self . get_caller_location ( & mut bx, span) . immediate ( ) ;
425424
426425 // Put together the arguments to the panic entry point.
427426 let ( lang_item, args) = match msg {
@@ -534,11 +533,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
534533 let ty = instance. unwrap ( ) . substs . type_at ( 0 ) ;
535534 let layout = bx. layout_of ( ty) ;
536535 if layout. abi . is_uninhabited ( ) {
537- let loc = bx. sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
538-
539536 let msg_str = format ! ( "Attempted to instantiate uninhabited type {}" , ty) ;
540537 let msg = bx. const_str ( Symbol :: intern ( & msg_str) ) ;
541- let location = bx . static_panic_location ( & loc ) ;
538+ let location = self . get_caller_location ( & mut bx , span ) . immediate ( ) ;
542539
543540 // Obtain the panic entry point.
544541 let def_id =
@@ -584,13 +581,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
584581
585582 if intrinsic == Some ( "caller_location" ) {
586583 if let Some ( ( _, target) ) = destination. as_ref ( ) {
587- let loc = bx. sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
588- let location = bx. static_panic_location ( & loc) ;
584+ let location = self . get_caller_location ( & mut bx, span) ;
589585
590586 if let ReturnDest :: IndirectOperand ( tmp, _) = ret_dest {
591- Immediate ( location) . store ( & mut bx, tmp) ;
587+ location. val . store ( & mut bx, tmp) ;
592588 }
593- self . store_return ( & mut bx, ret_dest, & fn_ty. ret , location) ;
589+ self . store_return ( & mut bx, ret_dest, & fn_ty. ret , location. immediate ( ) ) ;
594590
595591 helper. maybe_sideeffect ( self . mir , & mut bx, & [ * target] ) ;
596592 helper. funclet_br ( self , & mut bx, * target) ;
@@ -994,6 +990,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
994990 }
995991 }
996992
993+ fn get_caller_location (
994+ & mut self ,
995+ bx : & mut Bx ,
996+ span : Span ,
997+ ) -> OperandRef < ' tcx , Bx :: Value > {
998+ let caller = bx. tcx ( ) . sess . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
999+ let const_loc = bx. tcx ( ) . const_caller_location ( (
1000+ Symbol :: intern ( & caller. file . name . to_string ( ) ) ,
1001+ caller. line as u32 ,
1002+ caller. col_display as u32 + 1 ,
1003+ ) ) ;
1004+ OperandRef :: from_const ( bx, const_loc)
1005+ }
1006+
9971007 fn get_personality_slot (
9981008 & mut self ,
9991009 bx : & mut Bx
0 commit comments