@@ -63,7 +63,6 @@ thread_local! {
6363 static NO_TRIMMED_PATH : Cell <bool > = const { Cell :: new( false ) } ;
6464 static NO_QUERIES : Cell <bool > = const { Cell :: new( false ) } ;
6565 static NO_VISIBLE_PATH : Cell <bool > = const { Cell :: new( false ) } ;
66- static NO_VERBOSE_CONSTANTS : Cell <bool > = const { Cell :: new( false ) } ;
6766}
6867
6968macro_rules! define_helper {
@@ -118,9 +117,6 @@ define_helper!(
118117 /// Prevent selection of visible paths. `Display` impl of DefId will prefer
119118 /// visible (public) reexports of types as paths.
120119 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 ) ;
124120) ;
125121
126122/// The "region highlights" are used to control region printing during
@@ -600,7 +596,7 @@ pub trait PrettyPrinter<'tcx>:
600596 }
601597 ty:: FnPtr ( ref bare_fn) => p ! ( print( bare_fn) ) ,
602598 ty:: Infer ( infer_ty) => {
603- let verbose = self . tcx ( ) . sess . verbose ( ) ;
599+ let verbose = self . should_print_verbose ( ) ;
604600 if let ty:: TyVar ( ty_vid) = infer_ty {
605601 if let Some ( name) = self . ty_infer_name ( ty_vid) {
606602 p ! ( write( "{}" , name) )
@@ -642,7 +638,7 @@ pub trait PrettyPrinter<'tcx>:
642638 p ! ( print_def_path( def_id, & [ ] ) ) ;
643639 }
644640 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 ( ) ) )
646642 && self . tcx ( ) . def_kind ( data. item_def_id ) == DefKind :: ImplTraitPlaceholder
647643 {
648644 return self . pretty_print_opaque_impl_type ( data. item_def_id , data. substs ) ;
@@ -658,7 +654,7 @@ pub trait PrettyPrinter<'tcx>:
658654 // only affect certain debug messages (e.g. messages printed
659655 // from `rustc_middle::ty` during the computation of `tcx.predicates_of`),
660656 // 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 ( ) ) {
662658 p ! ( write( "Opaque({:?}, {:?})" , def_id, substs) ) ;
663659 return Ok ( self ) ;
664660 }
@@ -689,7 +685,7 @@ pub trait PrettyPrinter<'tcx>:
689685 hir:: Movability :: Static => p ! ( "static " ) ,
690686 }
691687
692- if !self . tcx ( ) . sess . verbose ( ) {
688+ if !self . should_print_verbose ( ) {
693689 p ! ( "generator" ) ;
694690 // FIXME(eddyb) should use `def_span`.
695691 if let Some ( did) = did. as_local ( ) {
@@ -725,7 +721,7 @@ pub trait PrettyPrinter<'tcx>:
725721 }
726722 ty:: Closure ( did, substs) => {
727723 p ! ( write( "[" ) ) ;
728- if !self . tcx ( ) . sess . verbose ( ) {
724+ if !self . should_print_verbose ( ) {
729725 p ! ( write( "closure" ) ) ;
730726 // FIXME(eddyb) should use `def_span`.
731727 if let Some ( did) = did. as_local ( ) {
@@ -763,7 +759,7 @@ pub trait PrettyPrinter<'tcx>:
763759 }
764760 ty:: Array ( ty, sz) => {
765761 p ! ( "[" , print( ty) , "; " ) ;
766- if ! NO_VERBOSE_CONSTANTS . with ( |flag| flag . get ( ) ) && self . tcx ( ) . sess . verbose ( ) {
762+ if self . should_print_verbose ( ) {
767763 p ! ( write( "{:?}" , sz) ) ;
768764 } else if let ty:: ConstKind :: Unevaluated ( ..) = sz. kind ( ) {
769765 // Do not try to evaluate unevaluated constants. If we are const evaluating an
@@ -1077,7 +1073,7 @@ pub trait PrettyPrinter<'tcx>:
10771073
10781074 // Special-case `Fn(...) -> ...` and re-sugar it.
10791075 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 ( ) {
10811077 if let ty:: Tuple ( tys) = principal. substs . type_at ( 0 ) . kind ( ) {
10821078 let mut projections = predicates. projection_bounds ( ) ;
10831079 if let ( Some ( proj) , None ) = ( projections. next ( ) , projections. next ( ) ) {
@@ -1185,7 +1181,7 @@ pub trait PrettyPrinter<'tcx>:
11851181 ) -> Result < Self :: Const , Self :: Error > {
11861182 define_scoped_cx ! ( self ) ;
11871183
1188- if ! NO_VERBOSE_CONSTANTS . with ( |flag| flag . get ( ) ) && self . tcx ( ) . sess . verbose ( ) {
1184+ if self . should_print_verbose ( ) {
11891185 p ! ( write( "Const({:?}: {:?})" , ct. kind( ) , ct. ty( ) ) ) ;
11901186 return Ok ( self ) ;
11911187 }
@@ -1420,7 +1416,7 @@ pub trait PrettyPrinter<'tcx>:
14201416 ) -> Result < Self :: Const , Self :: Error > {
14211417 define_scoped_cx ! ( self ) ;
14221418
1423- if ! NO_VERBOSE_CONSTANTS . with ( |flag| flag . get ( ) ) && self . tcx ( ) . sess . verbose ( ) {
1419+ if self . should_print_verbose ( ) {
14241420 p ! ( write( "ValTree({:?}: " , valtree) , print( ty) , ")" ) ;
14251421 return Ok ( self ) ;
14261422 }
@@ -1564,6 +1560,10 @@ pub trait PrettyPrinter<'tcx>:
15641560 Ok ( cx)
15651561 } )
15661562 }
1563+
1564+ fn should_print_verbose ( & self ) -> bool {
1565+ self . tcx ( ) . sess . verbose ( )
1566+ }
15671567}
15681568
15691569// HACK(eddyb) boxed to avoid moving around a large struct by-value.
@@ -1839,7 +1839,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
18391839 }
18401840 }
18411841
1842- let verbose = self . tcx . sess . verbose ( ) ;
1842+ let verbose = self . should_print_verbose ( ) ;
18431843 disambiguated_data. fmt_maybe_verbose ( & mut self , verbose) ?;
18441844
18451845 self . empty_path = false ;
@@ -1940,7 +1940,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
19401940 return true ;
19411941 }
19421942
1943- if self . tcx . sess . verbose ( ) {
1943+ if self . should_print_verbose ( ) {
19441944 return true ;
19451945 }
19461946
@@ -2012,7 +2012,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
20122012 return Ok ( self ) ;
20132013 }
20142014
2015- if self . tcx . sess . verbose ( ) {
2015+ if self . should_print_verbose ( ) {
20162016 p ! ( write( "{:?}" , region) ) ;
20172017 return Ok ( self ) ;
20182018 }
@@ -2218,7 +2218,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
22182218 // aren't named. Eventually, we might just want this as the default, but
22192219 // this is not *quite* right and changes the ordering of some output
22202220 // anyways.
2221- let ( new_value, map) = if self . tcx ( ) . sess . verbose ( ) {
2221+ let ( new_value, map) = if self . should_print_verbose ( ) {
22222222 let regions: Vec < _ > = value
22232223 . bound_vars ( )
22242224 . into_iter ( )
0 commit comments