@@ -387,10 +387,8 @@ fn relevant_crates(db: &dyn RootQueryDb, file_id: FileId) -> Arc<[Crate]> {
387387}
388388
389389#[ must_use]
390- pub struct DbPanicContext {
391- // prevent arbitrary construction
392- _priv : ( ) ,
393- }
390+ #[ non_exhaustive]
391+ pub struct DbPanicContext ;
394392
395393impl Drop for DbPanicContext {
396394 fn drop ( & mut self ) {
@@ -404,26 +402,26 @@ impl DbPanicContext {
404402 fn set_hook ( ) {
405403 let default_hook = panic:: take_hook ( ) ;
406404 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+ }
407409 DbPanicContext :: with_ctx ( |ctx| {
408410 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 " ) ;
412414 }
413415 }
414416 } ) ;
415- if let Some ( backtrace) = salsa:: Backtrace :: capture ( ) {
416- eprintln ! ( "{backtrace}" ) ;
417- }
418- default_hook ( panic_info) ;
419417 } ) ) ;
420418 }
421419
422420 static SET_HOOK : Once = Once :: new ( ) ;
423421 SET_HOOK . call_once ( set_hook) ;
424422
425423 Self :: with_ctx ( |ctx| ctx. push ( frame) ) ;
426- DbPanicContext { _priv : ( ) }
424+ DbPanicContext
427425 }
428426
429427 fn with_ctx ( f : impl FnOnce ( & mut Vec < String > ) ) {
0 commit comments