@@ -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 : SubstsRef < ' _ > ,
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(
@@ -486,7 +487,7 @@ impl fmt::Debug for ty::GenericParamDef {
486
487
487
488
impl fmt:: Debug for ty:: TraitDef {
488
489
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
489
- PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
490
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt : f } , |mut cx| {
490
491
let _ = cx. print_def_path (
491
492
self . def_id ,
492
493
None ,
@@ -500,7 +501,7 @@ impl fmt::Debug for ty::TraitDef {
500
501
501
502
impl fmt:: Debug for ty:: AdtDef {
502
503
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
503
- PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
504
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt : f } , |mut cx| {
504
505
let _ = cx. print_def_path (
505
506
self . did ,
506
507
None ,
@@ -522,7 +523,7 @@ impl<'tcx> fmt::Debug for ty::ClosureUpvar<'tcx> {
522
523
523
524
impl fmt:: Debug for ty:: UpvarId {
524
525
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
525
- PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
526
+ PrintCx :: with_tls_tcx ( FmtPrinter { fmt : f } , |mut cx| {
526
527
define_scoped_cx ! ( cx) ;
527
528
p ! ( write( "UpvarId({:?};`{}`;{:?})" ,
528
529
self . var_path. hir_id,
@@ -592,7 +593,7 @@ define_print! {
592
593
define_print ! {
593
594
( ) ty:: BoundRegion , ( self , cx) {
594
595
display {
595
- if cx. is_verbose {
596
+ if cx. config . is_verbose {
596
597
return self . print_debug( cx) ;
597
598
}
598
599
@@ -630,7 +631,7 @@ define_print! {
630
631
// NB: this must be kept in sync with the printing logic above.
631
632
impl ty:: BoundRegion {
632
633
fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
633
- if cx. is_verbose {
634
+ if cx. config . is_verbose {
634
635
return true ;
635
636
}
636
637
@@ -654,7 +655,7 @@ impl ty::BoundRegion {
654
655
define_print ! {
655
656
( ) ty:: PlaceholderRegion , ( self , cx) {
656
657
display {
657
- if cx. is_verbose {
658
+ if cx. config . is_verbose {
658
659
return self . print_debug( cx) ;
659
660
}
660
661
@@ -673,7 +674,7 @@ define_print! {
673
674
// NB: this must be kept in sync with the printing logic above.
674
675
impl ty:: PlaceholderRegion {
675
676
fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
676
- if cx. is_verbose {
677
+ if cx. config . is_verbose {
677
678
return true ;
678
679
}
679
680
@@ -689,7 +690,7 @@ impl ty::PlaceholderRegion {
689
690
define_print ! {
690
691
( ) ty:: RegionKind , ( self , cx) {
691
692
display {
692
- if cx. is_verbose {
693
+ if cx. config . is_verbose {
693
694
return self . print_debug( cx) ;
694
695
}
695
696
@@ -717,7 +718,7 @@ define_print! {
717
718
ty:: RePlaceholder ( p) => {
718
719
p!( print_display( p) )
719
720
}
720
- ty:: ReScope ( scope) if cx. identify_regions => {
721
+ ty:: ReScope ( scope) if cx. config . identify_regions => {
721
722
match scope. data {
722
723
region:: ScopeData :: Node =>
723
724
p!( write( "'{}s" , scope. item_local_id( ) . as_usize( ) ) ) ,
@@ -734,7 +735,7 @@ define_print! {
734
735
) ) ,
735
736
}
736
737
}
737
- ty:: ReVar ( region_vid) if cx. identify_regions => {
738
+ ty:: ReVar ( region_vid) if cx. config . identify_regions => {
738
739
p!( print_debug( region_vid) )
739
740
}
740
741
ty:: ReVar ( region_vid) => {
@@ -801,7 +802,7 @@ define_print! {
801
802
impl ty:: RegionKind {
802
803
// HACK(eddyb) `pub(crate)` only for `ty::print`.
803
804
pub ( crate ) fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
804
- if cx. is_verbose {
805
+ if cx. config . is_verbose {
805
806
return true ;
806
807
}
807
808
@@ -822,7 +823,7 @@ impl ty::RegionKind {
822
823
ty:: RePlaceholder ( p) => p. display_outputs_anything ( cx) ,
823
824
824
825
ty:: ReScope ( _) |
825
- ty:: ReVar ( _) if cx. identify_regions => true ,
826
+ ty:: ReVar ( _) if cx. config . identify_regions => true ,
826
827
827
828
ty:: ReVar ( region_vid) => region_vid. display_outputs_anything ( cx) ,
828
829
@@ -905,7 +906,7 @@ impl fmt::Debug for ty::FloatVid {
905
906
define_print ! {
906
907
( ) ty:: RegionVid , ( self , cx) {
907
908
display {
908
- if cx. is_verbose {
909
+ if cx. config . is_verbose {
909
910
return self . print_debug( cx) ;
910
911
}
911
912
@@ -934,7 +935,7 @@ define_print! {
934
935
// NB: this must be kept in sync with the printing logic above.
935
936
impl ty:: RegionVid {
936
937
fn display_outputs_anything < P > ( & self , cx : & mut PrintCx < ' _ , ' _ , ' _ , P > ) -> bool {
937
- if cx. is_verbose {
938
+ if cx. config . is_verbose {
938
939
return true ;
939
940
}
940
941
@@ -950,7 +951,7 @@ impl ty::RegionVid {
950
951
define_print ! {
951
952
( ) ty:: InferTy , ( self , cx) {
952
953
display {
953
- if cx. is_verbose {
954
+ if cx. config . is_verbose {
954
955
return self . print_debug( cx) ;
955
956
}
956
957
match * self {
@@ -997,7 +998,7 @@ impl fmt::Debug for ty::FloatVarValue {
997
998
for<'a> <T as ty::Lift<'a>>::Lifted: fmt::Display + TypeFoldable<'a>
998
999
{
999
1000
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1000
- PrintCx::with (|cx| cx.in_binder(cx.tcx.lift(self)
1001
+ PrintCx::with_tls_tcx (|cx| cx.in_binder(cx.tcx.lift(self)
1001
1002
.expect("could not lift for printing")))
1002
1003
}
1003
1004
}*/
@@ -1146,7 +1147,7 @@ define_print! {
1146
1147
p!( write( "Placeholder({:?})" , placeholder) )
1147
1148
}
1148
1149
Opaque ( def_id, substs) => {
1149
- if cx. is_verbose {
1150
+ if cx. config . is_verbose {
1150
1151
return p!( write( "Opaque({:?}, {:?})" , def_id, substs) ) ;
1151
1152
}
1152
1153
0 commit comments