@@ -15,7 +15,7 @@ use crate::traits::*;
15
15
16
16
use std:: borrow:: Cow ;
17
17
18
- use syntax:: symbol:: Symbol ;
18
+ use syntax:: { source_map :: Span , symbol:: Symbol } ;
19
19
20
20
use super :: { FunctionCx , LocalRef } ;
21
21
use super :: place:: PlaceRef ;
@@ -420,8 +420,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
420
420
self . set_debug_loc ( & mut bx, terminator. source_info ) ;
421
421
422
422
// 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 ( ) ;
425
424
426
425
// Put together the arguments to the panic entry point.
427
426
let ( lang_item, args) = match msg {
@@ -534,11 +533,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
534
533
let ty = instance. unwrap ( ) . substs . type_at ( 0 ) ;
535
534
let layout = bx. layout_of ( ty) ;
536
535
if layout. abi . is_uninhabited ( ) {
537
- let loc = bx. sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
538
-
539
536
let msg_str = format ! ( "Attempted to instantiate uninhabited type {}" , ty) ;
540
537
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 ( ) ;
542
539
543
540
// Obtain the panic entry point.
544
541
let def_id =
@@ -584,13 +581,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
584
581
585
582
if intrinsic == Some ( "caller_location" ) {
586
583
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) ;
589
585
590
586
if let ReturnDest :: IndirectOperand ( tmp, _) = ret_dest {
591
- Immediate ( location) . store ( & mut bx, tmp) ;
587
+ location. val . store ( & mut bx, tmp) ;
592
588
}
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 ( ) ) ;
594
590
595
591
helper. maybe_sideeffect ( self . mir , & mut bx, & [ * target] ) ;
596
592
helper. funclet_br ( self , & mut bx, * target) ;
@@ -994,6 +990,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
994
990
}
995
991
}
996
992
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
+
997
1007
fn get_personality_slot (
998
1008
& mut self ,
999
1009
bx : & mut Bx
0 commit comments