@@ -64,7 +64,7 @@ thread_local! {
64
64
static SHOULD_PREFIX_WITH_CRATE : Cell <bool > = const { Cell :: new( false ) } ;
65
65
static NO_TRIMMED_PATH : Cell <bool > = const { Cell :: new( false ) } ;
66
66
static FORCE_TRIMMED_PATH : Cell <bool > = const { Cell :: new( false ) } ;
67
- static NO_QUERIES : Cell <bool > = const { Cell :: new( false ) } ;
67
+ static REDUCED_QUERIES : Cell <bool > = const { Cell :: new( false ) } ;
68
68
static NO_VISIBLE_PATH : Cell <bool > = const { Cell :: new( false ) } ;
69
69
}
70
70
@@ -102,14 +102,14 @@ macro_rules! define_helper {
102
102
}
103
103
104
104
define_helper ! (
105
- /// Avoids running any queries during any prints that occur
105
+ /// Avoids running select queries during any prints that occur
106
106
/// during the closure. This may alter the appearance of some
107
107
/// types (e.g. forcing verbose printing for opaque types).
108
108
/// This method is used during some queries (e.g. `explicit_item_bounds`
109
109
/// for opaque types), to ensure that any debug printing that
110
110
/// occurs during the query computation does not end up recursively
111
111
/// calling the same query.
112
- fn with_no_queries ( NoQueriesGuard , NO_QUERIES ) ;
112
+ fn with_reduced_queries ( ReducedQueriesGuard , REDUCED_QUERIES ) ;
113
113
/// Force us to name impls with just the filename/line number. We
114
114
/// normally try to use types. But at some points, notably while printing
115
115
/// cycle errors, this can result in extra or suboptimal error output,
@@ -127,6 +127,15 @@ define_helper!(
127
127
fn with_no_visible_paths( NoVisibleGuard , NO_VISIBLE_PATH ) ;
128
128
) ;
129
129
130
+ /// Avoids running any queries during prints.
131
+ pub macro with_no_queries ( $e: expr) { {
132
+ $crate:: ty:: print:: with_reduced_queries!( $crate :: ty:: print:: with_forced_impl_filename_line!(
133
+ $crate :: ty:: print:: with_no_trimmed_paths!( $crate :: ty:: print:: with_no_visible_paths!(
134
+ $crate :: ty:: print:: with_forced_impl_filename_line!( $e)
135
+ ) )
136
+ ) )
137
+ } }
138
+
130
139
/// The "region highlights" are used to control region printing during
131
140
/// specific error messages. When a "region highlight" is enabled, it
132
141
/// gives an alternate way to print specific regions. For now, we
@@ -659,7 +668,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
659
668
p ! ( ")" )
660
669
}
661
670
ty:: FnDef ( def_id, args) => {
662
- if with_no_queries ( ) {
671
+ if with_reduced_queries ( ) {
663
672
p ! ( print_def_path( def_id, args) ) ;
664
673
} else {
665
674
let sig = self . tcx ( ) . fn_sig ( def_id) . instantiate ( self . tcx ( ) , args) ;
@@ -759,7 +768,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
759
768
return Ok ( ( ) ) ;
760
769
}
761
770
_ => {
762
- if with_no_queries ( ) {
771
+ if with_reduced_queries ( ) {
763
772
p ! ( print_def_path( def_id, & [ ] ) ) ;
764
773
return Ok ( ( ) ) ;
765
774
} else {
@@ -1876,7 +1885,8 @@ impl DerefMut for FmtPrinter<'_, '_> {
1876
1885
1877
1886
impl < ' a , ' tcx > FmtPrinter < ' a , ' tcx > {
1878
1887
pub fn new ( tcx : TyCtxt < ' tcx > , ns : Namespace ) -> Self {
1879
- let limit = if with_no_queries ( ) { Limit :: new ( 1048576 ) } else { tcx. type_length_limit ( ) } ;
1888
+ let limit =
1889
+ if with_reduced_queries ( ) { Limit :: new ( 1048576 ) } else { tcx. type_length_limit ( ) } ;
1880
1890
Self :: new_with_limit ( tcx, ns, limit)
1881
1891
}
1882
1892
@@ -2962,7 +2972,7 @@ define_print_and_forward_display! {
2962
2972
}
2963
2973
2964
2974
TraitRefPrintSugared <' tcx> {
2965
- if !with_no_queries ( )
2975
+ if !with_reduced_queries ( )
2966
2976
&& let Some ( kind) = cx. tcx( ) . fn_trait_kind_from_def_id( self . 0 . def_id)
2967
2977
&& let ty:: Tuple ( args) = self . 0 . args. type_at( 1 ) . kind( )
2968
2978
{
@@ -3050,7 +3060,7 @@ define_print_and_forward_display! {
3050
3060
// If we're printing verbosely, or don't want to invoke queries
3051
3061
// (`is_impl_trait_in_trait`), then fall back to printing the def path.
3052
3062
// This is likely what you want if you're debugging the compiler anyways.
3053
- if !( cx. should_print_verbose( ) || with_no_queries ( ) )
3063
+ if !( cx. should_print_verbose( ) || with_reduced_queries ( ) )
3054
3064
&& cx. tcx( ) . is_impl_trait_in_trait( self . def_id)
3055
3065
{
3056
3066
return cx. pretty_print_opaque_impl_type( self . def_id, self . args) ;
0 commit comments