@@ -313,17 +313,15 @@ pub fn panicking() -> bool {
313
313
#[ cold]
314
314
// If panic_immediate_abort, inline the abort call,
315
315
// otherwise avoid inlining because of it is cold path.
316
+ #[ cfg_attr( not( feature = "panic_immediate_abort" ) , track_caller) ]
316
317
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
317
318
#[ 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 < ' _ > ) -> ! {
319
320
if cfg ! ( feature = "panic_immediate_abort" ) {
320
321
unsafe { intrinsics:: abort ( ) }
321
322
}
322
323
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 ( ) ) ;
327
325
begin_panic_handler ( & info)
328
326
}
329
327
@@ -372,8 +370,7 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
372
370
373
371
let loc = info. location ( ) . unwrap ( ) ; // The current implementation always returns Some
374
372
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) ;
377
374
}
378
375
379
376
/// 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<'_>) -> ! {
386
383
// bloat at the call sites as much as possible
387
384
#[ cfg_attr( not( feature = "panic_immediate_abort" ) , inline( never) ) ]
388
385
#[ 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 ) ) -> ! {
390
388
if cfg ! ( feature = "panic_immediate_abort" ) {
391
389
unsafe { intrinsics:: abort ( ) }
392
390
}
@@ -397,8 +395,7 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
397
395
// we do start doing this, then we should propagate this allocation to
398
396
// be performed in the parent of this thread instead of the thread that's
399
397
// 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 ( ) ) ;
402
399
403
400
struct PanicPayload < A > {
404
401
inner : Option < A > ,
@@ -436,10 +433,8 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
436
433
fn rust_panic_with_hook (
437
434
payload : & mut dyn BoxMeUp ,
438
435
message : Option < & fmt:: Arguments < ' _ > > ,
439
- file_line_col : & ( & str , u32 , u32 ) ,
436
+ location : & Location < ' _ > ,
440
437
) -> ! {
441
- let ( file, line, col) = * file_line_col;
442
-
443
438
let panics = update_panic_count ( 1 ) ;
444
439
445
440
// If this is the third nested call (e.g., panics == 2, this is 0-indexed),
@@ -456,8 +451,7 @@ fn rust_panic_with_hook(
456
451
}
457
452
458
453
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) ;
461
455
HOOK_LOCK . read ( ) ;
462
456
match HOOK {
463
457
// Some platforms (like wasm) know that printing to stderr won't ever actually
0 commit comments