@@ -313,17 +313,15 @@ pub fn panicking() -> bool {
313313#[ cold]
314314// If panic_immediate_abort, inline the abort call,
315315// otherwise avoid inlining because of it is cold path.
316+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , track_caller) ]
316317#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
317318#[ cfg_attr( feature = "panic_immediate_abort" , inline) ]
318- pub fn begin_panic_fmt ( msg : & fmt:: Arguments < ' _ > , file_line_col : & ( & ' static str , u32 , u32 ) ) -> ! {
319+ pub fn begin_panic_fmt ( msg : & fmt:: Arguments < ' _ > ) -> ! {
319320 if cfg ! ( feature = "panic_immediate_abort" ) {
320321 unsafe { intrinsics:: abort ( ) }
321322 }
322323
323- // Just package everything into a `PanicInfo` and continue like libcore panics.
324- let ( file, line, col) = * file_line_col;
325- let location = Location :: internal_constructor ( file, line, col) ;
326- let info = PanicInfo :: internal_constructor ( Some ( msg) , & location) ;
324+ let info = PanicInfo :: internal_constructor ( Some ( msg) , Location :: caller ( ) ) ;
327325 begin_panic_handler ( & info)
328326}
329327
@@ -372,8 +370,7 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
372370
373371 let loc = info. location ( ) . unwrap ( ) ; // The current implementation always returns Some
374372 let msg = info. message ( ) . unwrap ( ) ; // The current implementation always returns Some
375- let file_line_col = ( loc. file ( ) , loc. line ( ) , loc. column ( ) ) ;
376- rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , info. message ( ) , & file_line_col) ;
373+ rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , info. message ( ) , loc) ;
377374}
378375
379376/// This is the entry point of panicking for the non-format-string variants of
@@ -386,7 +383,8 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
386383// bloat at the call sites as much as possible
387384#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
388385#[ cold]
389- pub fn begin_panic < M : Any + Send > ( msg : M , file_line_col : & ( & ' static str , u32 , u32 ) ) -> ! {
386+ #[ track_caller]
387+ pub fn begin_panic < M : Any + Send > ( msg : M , #[ cfg( bootstrap) ] _: & ( & str , u32 , u32 ) ) -> ! {
390388 if cfg ! ( feature = "panic_immediate_abort" ) {
391389 unsafe { intrinsics:: abort ( ) }
392390 }
@@ -397,8 +395,7 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
397395 // we do start doing this, then we should propagate this allocation to
398396 // be performed in the parent of this thread instead of the thread that's
399397 // panicking.
400-
401- rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , None , file_line_col) ;
398+ rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , None , Location :: caller ( ) ) ;
402399
403400 struct PanicPayload < A > {
404401 inner : Option < A > ,
@@ -436,10 +433,8 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
436433fn rust_panic_with_hook (
437434 payload : & mut dyn BoxMeUp ,
438435 message : Option < & fmt:: Arguments < ' _ > > ,
439- file_line_col : & ( & str , u32 , u32 ) ,
436+ location : & Location < ' _ > ,
440437) -> ! {
441- let ( file, line, col) = * file_line_col;
442-
443438 let panics = update_panic_count ( 1 ) ;
444439
445440 // If this is the third nested call (e.g., panics == 2, this is 0-indexed),
@@ -456,8 +451,7 @@ fn rust_panic_with_hook(
456451 }
457452
458453 unsafe {
459- let location = Location :: internal_constructor ( file, line, col) ;
460- let mut info = PanicInfo :: internal_constructor ( message, & location) ;
454+ let mut info = PanicInfo :: internal_constructor ( message, location) ;
461455 HOOK_LOCK . read ( ) ;
462456 match HOOK {
463457 // Some platforms (like wasm) know that printing to stderr won't ever actually
0 commit comments