@@ -63,7 +63,6 @@ thread_local! {
63
63
static NO_TRIMMED_PATH : Cell <bool > = const { Cell :: new( false ) } ;
64
64
static NO_QUERIES : Cell <bool > = const { Cell :: new( false ) } ;
65
65
static NO_VISIBLE_PATH : Cell <bool > = const { Cell :: new( false ) } ;
66
- static NO_VERBOSE_CONSTANTS : Cell <bool > = const { Cell :: new( false ) } ;
67
66
}
68
67
69
68
macro_rules! define_helper {
@@ -118,9 +117,6 @@ define_helper!(
118
117
/// Prevent selection of visible paths. `Display` impl of DefId will prefer
119
118
/// visible (public) reexports of types as paths.
120
119
fn with_no_visible_paths( NoVisibleGuard , NO_VISIBLE_PATH ) ;
121
- /// Prevent verbose printing of constants. Verbose printing of constants is
122
- /// never desirable in some contexts like `std::any::type_name`.
123
- fn with_no_verbose_constants( NoVerboseConstantsGuard , NO_VERBOSE_CONSTANTS ) ;
124
120
) ;
125
121
126
122
/// The "region highlights" are used to control region printing during
@@ -600,7 +596,7 @@ pub trait PrettyPrinter<'tcx>:
600
596
}
601
597
ty:: FnPtr ( ref bare_fn) => p ! ( print( bare_fn) ) ,
602
598
ty:: Infer ( infer_ty) => {
603
- let verbose = self . tcx ( ) . sess . verbose ( ) ;
599
+ let verbose = self . should_print_verbose ( ) ;
604
600
if let ty:: TyVar ( ty_vid) = infer_ty {
605
601
if let Some ( name) = self . ty_infer_name ( ty_vid) {
606
602
p ! ( write( "{}" , name) )
@@ -642,7 +638,7 @@ pub trait PrettyPrinter<'tcx>:
642
638
p ! ( print_def_path( def_id, & [ ] ) ) ;
643
639
}
644
640
ty:: Projection ( ref data) => {
645
- if !( self . tcx ( ) . sess . verbose ( ) || NO_QUERIES . with ( |q| q. get ( ) ) )
641
+ if !( self . should_print_verbose ( ) || NO_QUERIES . with ( |q| q. get ( ) ) )
646
642
&& self . tcx ( ) . def_kind ( data. item_def_id ) == DefKind :: ImplTraitPlaceholder
647
643
{
648
644
return self . pretty_print_opaque_impl_type ( data. item_def_id , data. substs ) ;
@@ -658,7 +654,7 @@ pub trait PrettyPrinter<'tcx>:
658
654
// only affect certain debug messages (e.g. messages printed
659
655
// from `rustc_middle::ty` during the computation of `tcx.predicates_of`),
660
656
// and should have no effect on any compiler output.
661
- if self . tcx ( ) . sess . verbose ( ) || NO_QUERIES . with ( |q| q. get ( ) ) {
657
+ if self . should_print_verbose ( ) || NO_QUERIES . with ( |q| q. get ( ) ) {
662
658
p ! ( write( "Opaque({:?}, {:?})" , def_id, substs) ) ;
663
659
return Ok ( self ) ;
664
660
}
@@ -689,7 +685,7 @@ pub trait PrettyPrinter<'tcx>:
689
685
hir:: Movability :: Static => p ! ( "static " ) ,
690
686
}
691
687
692
- if !self . tcx ( ) . sess . verbose ( ) {
688
+ if !self . should_print_verbose ( ) {
693
689
p ! ( "generator" ) ;
694
690
// FIXME(eddyb) should use `def_span`.
695
691
if let Some ( did) = did. as_local ( ) {
@@ -725,7 +721,7 @@ pub trait PrettyPrinter<'tcx>:
725
721
}
726
722
ty:: Closure ( did, substs) => {
727
723
p ! ( write( "[" ) ) ;
728
- if !self . tcx ( ) . sess . verbose ( ) {
724
+ if !self . should_print_verbose ( ) {
729
725
p ! ( write( "closure" ) ) ;
730
726
// FIXME(eddyb) should use `def_span`.
731
727
if let Some ( did) = did. as_local ( ) {
@@ -763,7 +759,7 @@ pub trait PrettyPrinter<'tcx>:
763
759
}
764
760
ty:: Array ( ty, sz) => {
765
761
p ! ( "[" , print( ty) , "; " ) ;
766
- if ! NO_VERBOSE_CONSTANTS . with ( |flag| flag . get ( ) ) && self . tcx ( ) . sess . verbose ( ) {
762
+ if self . should_print_verbose ( ) {
767
763
p ! ( write( "{:?}" , sz) ) ;
768
764
} else if let ty:: ConstKind :: Unevaluated ( ..) = sz. kind ( ) {
769
765
// Do not try to evaluate unevaluated constants. If we are const evaluating an
@@ -1077,7 +1073,7 @@ pub trait PrettyPrinter<'tcx>:
1077
1073
1078
1074
// Special-case `Fn(...) -> ...` and re-sugar it.
1079
1075
let fn_trait_kind = cx. tcx ( ) . fn_trait_kind_from_lang_item ( principal. def_id ) ;
1080
- if !cx. tcx ( ) . sess . verbose ( ) && fn_trait_kind. is_some ( ) {
1076
+ if !cx. should_print_verbose ( ) && fn_trait_kind. is_some ( ) {
1081
1077
if let ty:: Tuple ( tys) = principal. substs . type_at ( 0 ) . kind ( ) {
1082
1078
let mut projections = predicates. projection_bounds ( ) ;
1083
1079
if let ( Some ( proj) , None ) = ( projections. next ( ) , projections. next ( ) ) {
@@ -1185,7 +1181,7 @@ pub trait PrettyPrinter<'tcx>:
1185
1181
) -> Result < Self :: Const , Self :: Error > {
1186
1182
define_scoped_cx ! ( self ) ;
1187
1183
1188
- if ! NO_VERBOSE_CONSTANTS . with ( |flag| flag . get ( ) ) && self . tcx ( ) . sess . verbose ( ) {
1184
+ if self . should_print_verbose ( ) {
1189
1185
p ! ( write( "Const({:?}: {:?})" , ct. kind( ) , ct. ty( ) ) ) ;
1190
1186
return Ok ( self ) ;
1191
1187
}
@@ -1420,7 +1416,7 @@ pub trait PrettyPrinter<'tcx>:
1420
1416
) -> Result < Self :: Const , Self :: Error > {
1421
1417
define_scoped_cx ! ( self ) ;
1422
1418
1423
- if ! NO_VERBOSE_CONSTANTS . with ( |flag| flag . get ( ) ) && self . tcx ( ) . sess . verbose ( ) {
1419
+ if self . should_print_verbose ( ) {
1424
1420
p ! ( write( "ValTree({:?}: " , valtree) , print( ty) , ")" ) ;
1425
1421
return Ok ( self ) ;
1426
1422
}
@@ -1564,6 +1560,10 @@ pub trait PrettyPrinter<'tcx>:
1564
1560
Ok ( cx)
1565
1561
} )
1566
1562
}
1563
+
1564
+ fn should_print_verbose ( & self ) -> bool {
1565
+ self . tcx ( ) . sess . verbose ( )
1566
+ }
1567
1567
}
1568
1568
1569
1569
// HACK(eddyb) boxed to avoid moving around a large struct by-value.
@@ -1839,7 +1839,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
1839
1839
}
1840
1840
}
1841
1841
1842
- let verbose = self . tcx . sess . verbose ( ) ;
1842
+ let verbose = self . should_print_verbose ( ) ;
1843
1843
disambiguated_data. fmt_maybe_verbose ( & mut self , verbose) ?;
1844
1844
1845
1845
self . empty_path = false ;
@@ -1940,7 +1940,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
1940
1940
return true ;
1941
1941
}
1942
1942
1943
- if self . tcx . sess . verbose ( ) {
1943
+ if self . should_print_verbose ( ) {
1944
1944
return true ;
1945
1945
}
1946
1946
@@ -2012,7 +2012,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
2012
2012
return Ok ( self ) ;
2013
2013
}
2014
2014
2015
- if self . tcx . sess . verbose ( ) {
2015
+ if self . should_print_verbose ( ) {
2016
2016
p ! ( write( "{:?}" , region) ) ;
2017
2017
return Ok ( self ) ;
2018
2018
}
@@ -2218,7 +2218,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
2218
2218
// aren't named. Eventually, we might just want this as the default, but
2219
2219
// this is not *quite* right and changes the ordering of some output
2220
2220
// anyways.
2221
- let ( new_value, map) = if self . tcx ( ) . sess . verbose ( ) {
2221
+ let ( new_value, map) = if self . should_print_verbose ( ) {
2222
2222
let regions: Vec < _ > = value
2223
2223
. bound_vars ( )
2224
2224
. into_iter ( )
0 commit comments