@@ -387,10 +387,8 @@ fn relevant_crates(db: &dyn RootQueryDb, file_id: FileId) -> Arc<[Crate]> {
387
387
}
388
388
389
389
#[ must_use]
390
- pub struct DbPanicContext {
391
- // prevent arbitrary construction
392
- _priv : ( ) ,
393
- }
390
+ #[ non_exhaustive]
391
+ pub struct DbPanicContext ;
394
392
395
393
impl Drop for DbPanicContext {
396
394
fn drop ( & mut self ) {
@@ -404,26 +402,26 @@ impl DbPanicContext {
404
402
fn set_hook ( ) {
405
403
let default_hook = panic:: take_hook ( ) ;
406
404
panic:: set_hook ( Box :: new ( move |panic_info| {
405
+ default_hook ( panic_info) ;
406
+ if let Some ( backtrace) = salsa:: Backtrace :: capture ( ) {
407
+ eprintln ! ( "{backtrace:#}" ) ;
408
+ }
407
409
DbPanicContext :: with_ctx ( |ctx| {
408
410
if !ctx. is_empty ( ) {
409
- eprintln ! ( "Panic context:" ) ;
410
- for frame in ctx. iter ( ) {
411
- eprintln ! ( "> {frame}\n " ) ;
411
+ eprintln ! ( "additional context:" ) ;
412
+ for ( idx , frame) in ctx. iter ( ) . enumerate ( ) {
413
+ eprintln ! ( "{idx:>4}: {frame}\n " ) ;
412
414
}
413
415
}
414
416
} ) ;
415
- if let Some ( backtrace) = salsa:: Backtrace :: capture ( ) {
416
- eprintln ! ( "{backtrace}" ) ;
417
- }
418
- default_hook ( panic_info) ;
419
417
} ) ) ;
420
418
}
421
419
422
420
static SET_HOOK : Once = Once :: new ( ) ;
423
421
SET_HOOK . call_once ( set_hook) ;
424
422
425
423
Self :: with_ctx ( |ctx| ctx. push ( frame) ) ;
426
- DbPanicContext { _priv : ( ) }
424
+ DbPanicContext
427
425
}
428
426
429
427
fn with_ctx ( f : impl FnOnce ( & mut Vec < String > ) ) {
0 commit comments