@@ -575,18 +575,6 @@ macro_rules! expand_if_cached {
575575 } ;
576576}
577577
578- /// Don't show the backtrace for query system by default
579- /// use `RUST_BACKTRACE=full` to show all the backtraces
580- #[ inline( never) ]
581- pub ( crate ) fn __rust_begin_short_backtrace < F , T > ( f : F ) -> T
582- where
583- F : FnOnce ( ) -> T ,
584- {
585- let result = f ( ) ;
586- std:: hint:: black_box ( ( ) ) ;
587- result
588- }
589-
590578// NOTE: `$V` isn't used here, but we still need to match on it so it can be passed to other macros
591579// invoked by `rustc_with_all_queries`.
592580macro_rules! define_queries {
@@ -645,6 +633,32 @@ macro_rules! define_queries {
645633 }
646634 }
647635
636+ /// Defines a `compute` function for this query, to be used as a
637+ /// function pointer in the query's vtable.
638+ mod compute_fn {
639+ use super :: * ;
640+ use :: rustc_middle:: query:: queries:: $name:: { Key , Value , provided_to_erased} ;
641+
642+ /// This function would be named `compute`, but we also want it
643+ /// to mark the boundaries of an omitted region in backtraces.
644+ #[ inline( never) ]
645+ pub ( crate ) fn __rust_begin_short_backtrace<' tcx>(
646+ tcx: TyCtxt <' tcx>,
647+ key: Key <' tcx>,
648+ ) -> Erased <Value <' tcx>> {
649+ #[ cfg( debug_assertions) ]
650+ let _guard = tracing:: span!( tracing:: Level :: TRACE , stringify!( $name) , ?key) . entered( ) ;
651+
652+ // Call the actual provider function for this query.
653+ let provided_value = call_provider!( [ $( $modifiers) * ] [ tcx, $name, key] ) ;
654+ rustc_middle:: ty:: print:: with_reduced_queries!( {
655+ tracing:: trace!( ?provided_value) ;
656+ } ) ;
657+
658+ provided_to_erased( tcx, provided_value)
659+ }
660+ }
661+
648662 pub ( crate ) fn make_query_vtable<' tcx>( )
649663 -> QueryVTable <' tcx, queries:: $name:: Storage <' tcx>>
650664 {
@@ -657,22 +671,7 @@ macro_rules! define_queries {
657671 query_cache: std:: mem:: offset_of!( QueryCaches <' tcx>, $name) ,
658672 cache_on_disk: |tcx, key| :: rustc_middle:: query:: cached:: $name( tcx, key) ,
659673 execute_query: |tcx, key| erase:: erase_val( tcx. $name( key) ) ,
660- compute: |tcx, key| {
661- #[ cfg( debug_assertions) ]
662- let _guard = tracing:: span!( tracing:: Level :: TRACE , stringify!( $name) , ?key) . entered( ) ;
663- __rust_begin_short_backtrace( ||
664- queries:: $name:: provided_to_erased(
665- tcx,
666- {
667- let ret = call_provider!( [ $( $modifiers) * ] [ tcx, $name, key] ) ;
668- rustc_middle:: ty:: print:: with_reduced_queries!( {
669- tracing:: trace!( ?ret) ;
670- } ) ;
671- ret
672- }
673- )
674- )
675- } ,
674+ compute_fn: self :: compute_fn:: __rust_begin_short_backtrace,
676675 can_load_from_disk: should_ever_cache_on_disk!( [ $( $modifiers) * ] true false ) ,
677676 try_load_from_disk: should_ever_cache_on_disk!( [ $( $modifiers) * ] {
678677 |tcx, key, prev_index, index| {
0 commit comments