@@ -161,7 +161,7 @@ impl RegionHighlightMode {
161
161
macro_rules! gen_display_debug_body {
162
162
( $with: path ) => {
163
163
fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
164
- PrintCx :: with ( FmtPrinter { fmt: f } , |mut cx| {
164
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt: f } , |mut cx| {
165
165
$with( & cx. tcx. lift( self ) . expect( "could not lift for printing" ) , & mut cx)
166
166
} )
167
167
}
@@ -197,7 +197,7 @@ macro_rules! gen_print_impl {
197
197
type Error = fmt:: Error ;
198
198
fn print( & $self, $cx: & mut PrintCx <' _, ' _, ' tcx, P >) -> fmt:: Result {
199
199
define_scoped_cx!( $cx) ;
200
- if $cx. is_debug $dbg
200
+ if $cx. config . is_debug $dbg
201
201
else $disp
202
202
}
203
203
}
@@ -208,7 +208,7 @@ macro_rules! gen_print_impl {
208
208
type Error = fmt:: Error ;
209
209
fn print( & $self, $cx: & mut PrintCx <' _, ' _, ' tcx, P >) -> fmt:: Result {
210
210
define_scoped_cx!( $cx) ;
211
- if $cx. is_debug $dbg
211
+ if $cx. config . is_debug $dbg
212
212
else $disp
213
213
}
214
214
}
@@ -316,7 +316,7 @@ impl<P: PrettyPrinter> PrintCx<'a, 'gcx, 'tcx, P> {
316
316
// clearly differentiate between named and unnamed regions in
317
317
// the output. We'll probably want to tweak this over time to
318
318
// decide just how much information to give.
319
- if self . binder_depth == 0 {
319
+ if self . config . binder_depth == 0 {
320
320
self . prepare_late_bound_region_info ( value) ;
321
321
}
322
322
@@ -337,7 +337,7 @@ impl<P: PrettyPrinter> PrintCx<'a, 'gcx, 'tcx, P> {
337
337
// is disallowed (name resolution thinks `scoped_cx!` is ambiguous).
338
338
define_scoped_cx ! ( self ) ;
339
339
340
- let old_region_index = self . region_index ;
340
+ let old_region_index = self . config . region_index ;
341
341
let mut region_index = old_region_index;
342
342
let new_value = self . tcx . replace_late_bound_regions ( value, |br| {
343
343
let _ = start_or_continue ( self , "for<" , ", " ) ;
@@ -365,16 +365,16 @@ impl<P: PrettyPrinter> PrintCx<'a, 'gcx, 'tcx, P> {
365
365
start_or_continue ( self , "" , "> " ) ?;
366
366
367
367
// Push current state to gcx, and restore after writing new_value.
368
- self . binder_depth += 1 ;
369
- self . region_index = region_index;
368
+ self . config . binder_depth += 1 ;
369
+ self . config . region_index = region_index;
370
370
let result = new_value. print_display ( self ) ;
371
- self . region_index = old_region_index;
372
- self . binder_depth -= 1 ;
371
+ self . config . region_index = old_region_index;
372
+ self . config . binder_depth -= 1 ;
373
373
result
374
374
}
375
375
376
376
fn is_name_used ( & self , name : & InternedString ) -> bool {
377
- match self . used_region_names {
377
+ match self . config . used_region_names {
378
378
Some ( ref names) => names. contains ( name) ,
379
379
None => false ,
380
380
}
@@ -387,7 +387,7 @@ pub fn parameterized<F: fmt::Write>(
387
387
substs : & Substs < ' _ > ,
388
388
ns : Namespace ,
389
389
) -> fmt:: Result {
390
- PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
390
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt : f } , |mut cx| {
391
391
let substs = cx. tcx . lift ( & substs) . expect ( "could not lift for printing" ) ;
392
392
let _ = cx. print_def_path ( did, Some ( substs) , ns, iter:: empty ( ) ) ?;
393
393
Ok ( ( ) )
@@ -404,8 +404,9 @@ define_print! {
404
404
let mut resugared_principal = false ;
405
405
406
406
// Special-case `Fn(...) -> ...` and resugar it.
407
- if !cx. is_verbose && cx. tcx. lang_items( ) . fn_trait_kind( principal. def_id) . is_some( ) {
408
- if let Tuple ( ref args) = principal. substs. type_at( 0 ) . sty {
407
+ let fn_trait_kind = cx. tcx. lang_items( ) . fn_trait_kind( principal. def_id) ;
408
+ if !cx. config. is_verbose && fn_trait_kind. is_some( ) {
409
+ if let ty:: Tuple ( ref args) = principal. substs. type_at( 0 ) . sty {
409
410
let mut projections = self . projection_bounds( ) ;
410
411
if let ( Some ( proj) , None ) = ( projections. next( ) , projections. next( ) ) {
411
412
let _ = cx. print_def_path(
@@ -485,7 +486,7 @@ impl fmt::Debug for ty::GenericParamDef {
485
486
486
487
impl fmt:: Debug for ty:: TraitDef {
487
488
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
488
- PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
489
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt : f } , |mut cx| {
489
490
let _ = cx. print_def_path (
490
491
self . def_id ,
491
492
None ,
@@ -499,7 +500,7 @@ impl fmt::Debug for ty::TraitDef {
499
500
500
501
impl fmt:: Debug for ty:: AdtDef {
501
502
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
502
- PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
503
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt : f } , |mut cx| {
503
504
let _ = cx. print_def_path (
504
505
self . did ,
505
506
None ,
@@ -521,7 +522,7 @@ impl<'tcx> fmt::Debug for ty::ClosureUpvar<'tcx> {
521
522
522
523
impl fmt:: Debug for ty:: UpvarId {
523
524
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
524
- PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
525
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt : f } , |mut cx| {
525
526
define_scoped_cx ! ( cx) ;
526
527
p ! ( write( "UpvarId({:?};`{}`;{:?})" ,
527
528
self . var_path. hir_id,
@@ -591,7 +592,7 @@ define_print! {
591
592
define_print ! {
592
593
( ) ty:: BoundRegion , ( self , cx) {
593
594
display {
594
- if cx. is_verbose {
595
+ if cx. config . is_verbose {
595
596
return self . print_debug( cx) ;
596
597
}
597
598
@@ -629,7 +630,7 @@ define_print! {
629
630
// NB: this must be kept in sync with the printing logic above.
630
631
impl ty:: BoundRegion {
631
632
fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
632
- if cx. is_verbose {
633
+ if cx. config . is_verbose {
633
634
return true ;
634
635
}
635
636
@@ -653,7 +654,7 @@ impl ty::BoundRegion {
653
654
define_print ! {
654
655
( ) ty:: PlaceholderRegion , ( self , cx) {
655
656
display {
656
- if cx. is_verbose {
657
+ if cx. config . is_verbose {
657
658
return self . print_debug( cx) ;
658
659
}
659
660
@@ -672,7 +673,7 @@ define_print! {
672
673
// NB: this must be kept in sync with the printing logic above.
673
674
impl ty:: PlaceholderRegion {
674
675
fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
675
- if cx. is_verbose {
676
+ if cx. config . is_verbose {
676
677
return true ;
677
678
}
678
679
@@ -688,7 +689,7 @@ impl ty::PlaceholderRegion {
688
689
define_print ! {
689
690
( ) ty:: RegionKind , ( self , cx) {
690
691
display {
691
- if cx. is_verbose {
692
+ if cx. config . is_verbose {
692
693
return self . print_debug( cx) ;
693
694
}
694
695
@@ -716,7 +717,7 @@ define_print! {
716
717
ty:: RePlaceholder ( p) => {
717
718
p!( print_display( p) )
718
719
}
719
- ty:: ReScope ( scope) if cx. identify_regions => {
720
+ ty:: ReScope ( scope) if cx. config . identify_regions => {
720
721
match scope. data {
721
722
region:: ScopeData :: Node =>
722
723
p!( write( "'{}s" , scope. item_local_id( ) . as_usize( ) ) ) ,
@@ -733,7 +734,7 @@ define_print! {
733
734
) ) ,
734
735
}
735
736
}
736
- ty:: ReVar ( region_vid) if cx. identify_regions => {
737
+ ty:: ReVar ( region_vid) if cx. config . identify_regions => {
737
738
p!( print_debug( region_vid) )
738
739
}
739
740
ty:: ReVar ( region_vid) => {
@@ -800,7 +801,7 @@ define_print! {
800
801
impl ty:: RegionKind {
801
802
// HACK(eddyb) `pub(crate)` only for `ty::print`.
802
803
pub ( crate ) fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
803
- if cx. is_verbose {
804
+ if cx. config . is_verbose {
804
805
return true ;
805
806
}
806
807
@@ -821,7 +822,7 @@ impl ty::RegionKind {
821
822
ty:: RePlaceholder ( p) => p. display_outputs_anything ( cx) ,
822
823
823
824
ty:: ReScope ( _) |
824
- ty:: ReVar ( _) if cx. identify_regions => true ,
825
+ ty:: ReVar ( _) if cx. config . identify_regions => true ,
825
826
826
827
ty:: ReVar ( region_vid) => region_vid. display_outputs_anything ( cx) ,
827
828
@@ -898,7 +899,7 @@ impl fmt::Debug for ty::FloatVid {
898
899
define_print ! {
899
900
( ) ty:: RegionVid , ( self , cx) {
900
901
display {
901
- if cx. is_verbose {
902
+ if cx. config . is_verbose {
902
903
return self . print_debug( cx) ;
903
904
}
904
905
@@ -927,7 +928,7 @@ define_print! {
927
928
// NB: this must be kept in sync with the printing logic above.
928
929
impl ty:: RegionVid {
929
930
fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
930
- if cx. is_verbose {
931
+ if cx. config . is_verbose {
931
932
return true ;
932
933
}
933
934
@@ -943,7 +944,7 @@ impl ty::RegionVid {
943
944
define_print ! {
944
945
( ) ty:: InferTy , ( self , cx) {
945
946
display {
946
- if cx. is_verbose {
947
+ if cx. config . is_verbose {
947
948
return self . print_debug( cx) ;
948
949
}
949
950
match * self {
@@ -990,7 +991,7 @@ impl fmt::Debug for ty::FloatVarValue {
990
991
for<'a> <T as ty::Lift<'a>>::Lifted: fmt::Display + TypeFoldable<'a>
991
992
{
992
993
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
993
- PrintCx::with (|cx| cx.in_binder(cx.tcx.lift(self)
994
+ PrintCx::with_tls_tcx (|cx| cx.in_binder(cx.tcx.lift(self)
994
995
.expect("could not lift for printing")))
995
996
}
996
997
}*/
@@ -1139,7 +1140,7 @@ define_print! {
1139
1140
p!( write( "Placeholder({:?})" , placeholder) )
1140
1141
}
1141
1142
Opaque ( def_id, substs) => {
1142
- if cx. is_verbose {
1143
+ if cx. config . is_verbose {
1143
1144
return p!( write( "Opaque({:?}, {:?})" , def_id, substs) ) ;
1144
1145
}
1145
1146
0 commit comments