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