@@ -10,10 +10,10 @@ use ty::{Param, Bound, RawPtr, Ref, Never, Tuple};
10
10
use ty:: { Closure , Generator , GeneratorWitness , Foreign , Projection , Opaque } ;
11
11
use ty:: { Placeholder , UnnormalizedProjection , Dynamic , Int , Uint , Infer } ;
12
12
use ty:: { self , Ty , TypeFoldable } ;
13
- use ty:: print:: { FmtPrinter , PrintCx , Print } ;
13
+ use ty:: print:: { FmtPrinter , PrettyPrinter , PrintCx , Print } ;
14
14
15
15
use std:: cell:: Cell ;
16
- use std:: fmt;
16
+ use std:: fmt:: { self , Write as _ } ;
17
17
use std:: iter;
18
18
use std:: usize;
19
19
@@ -193,18 +193,18 @@ macro_rules! gen_display_debug {
193
193
}
194
194
macro_rules! gen_print_impl {
195
195
( ( $( $x: tt) +) $target: ty, ( $self: ident, $cx: ident) $disp: block $dbg: block ) => {
196
- impl <$( $x) +, F : fmt :: Write > Print <' tcx, FmtPrinter < F > > for $target {
196
+ impl <$( $x) +, P : PrettyPrinter > Print <' tcx, P > for $target {
197
197
type Output = fmt:: Result ;
198
- fn print( & $self, $cx: & mut PrintCx <' _, ' _, ' tcx, FmtPrinter < F > >) -> fmt:: Result {
198
+ fn print( & $self, $cx: & mut PrintCx <' _, ' _, ' tcx, P >) -> fmt:: Result {
199
199
if $cx. is_debug $dbg
200
200
else $disp
201
201
}
202
202
}
203
203
} ;
204
204
( ( ) $target: ty, ( $self: ident, $cx: ident) $disp: block $dbg: block ) => {
205
- impl <F : fmt :: Write > Print <' tcx, FmtPrinter < F > > for $target {
205
+ impl <P : PrettyPrinter > Print <' tcx, P > for $target {
206
206
type Output = fmt:: Result ;
207
- fn print( & $self, $cx: & mut PrintCx <' _, ' _, ' tcx, FmtPrinter < F > >) -> fmt:: Result {
207
+ fn print( & $self, $cx: & mut PrintCx <' _, ' _, ' tcx, P >) -> fmt:: Result {
208
208
if $cx. is_debug $dbg
209
209
else $disp
210
210
}
@@ -235,7 +235,7 @@ macro_rules! define_print {
235
235
( $generic: tt $target: ty,
236
236
( $self: ident, $cx: ident) { display $disp: block } ) => {
237
237
gen_print_impl! { $generic $target, ( $self, $cx) yes $disp no {
238
- write!( $cx. printer. fmt , "{:?}" , $self)
238
+ write!( $cx. printer, "{:?}" , $self)
239
239
} }
240
240
} ;
241
241
}
@@ -246,7 +246,7 @@ macro_rules! define_print_multi {
246
246
}
247
247
macro_rules! print_inner {
248
248
( $cx: expr, write ( $( $data: expr) ,+) ) => {
249
- write!( $cx. printer. fmt , $( $data) ,+)
249
+ write!( $cx. printer, $( $data) ,+)
250
250
} ;
251
251
( $cx: expr, $kind: ident ( $data: expr) ) => {
252
252
$data. $kind( $cx)
@@ -258,7 +258,7 @@ macro_rules! print {
258
258
} ;
259
259
}
260
260
261
- impl < F : fmt :: Write > PrintCx < ' a , ' gcx , ' tcx , FmtPrinter < F > > {
261
+ impl < P : PrettyPrinter > PrintCx < ' a , ' gcx , ' tcx , P > {
262
262
fn fn_sig (
263
263
& mut self ,
264
264
inputs : & [ Ty < ' tcx > ] ,
@@ -404,7 +404,7 @@ impl<F: fmt::Write> PrintCx<'a, 'gcx, 'tcx, FmtPrinter<F>> {
404
404
}
405
405
406
406
fn in_binder < T > ( & mut self , value : & ty:: Binder < T > ) -> fmt:: Result
407
- where T : Print < ' tcx , FmtPrinter < F > , Output = fmt:: Result > + TypeFoldable < ' tcx >
407
+ where T : Print < ' tcx , P , Output = fmt:: Result > + TypeFoldable < ' tcx >
408
408
{
409
409
fn name_by_region_index ( index : usize ) -> InternedString {
410
410
match index {
@@ -489,13 +489,6 @@ pub fn parameterized<F: fmt::Write>(
489
489
} )
490
490
}
491
491
492
- impl < ' a , ' tcx , P , T : Print < ' tcx , P > > Print < ' tcx , P > for & ' a T {
493
- type Output = T :: Output ;
494
- fn print ( & self , cx : & mut PrintCx < ' _ , ' _ , ' tcx , P > ) -> Self :: Output {
495
- ( * self ) . print ( cx)
496
- }
497
- }
498
-
499
492
define_print ! {
500
493
( ' tcx) & ' tcx ty:: List <ty:: ExistentialPredicate <' tcx>>, ( self , cx) {
501
494
display {
@@ -575,15 +568,15 @@ impl fmt::Debug for ty::GenericParamDef {
575
568
576
569
impl fmt:: Debug for ty:: TraitDef {
577
570
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
578
- PrintCx :: with ( FmtPrinter { fmt : f } , |cx| {
571
+ PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
579
572
print ! ( cx, write( "{}" , cx. tcx. def_path_str( self . def_id) ) )
580
573
} )
581
574
}
582
575
}
583
576
584
577
impl fmt:: Debug for ty:: AdtDef {
585
578
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
586
- PrintCx :: with ( FmtPrinter { fmt : f } , |cx| {
579
+ PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
587
580
print ! ( cx, write( "{}" , cx. tcx. def_path_str( self . did) ) )
588
581
} )
589
582
}
@@ -599,7 +592,7 @@ impl<'tcx> fmt::Debug for ty::ClosureUpvar<'tcx> {
599
592
600
593
impl fmt:: Debug for ty:: UpvarId {
601
594
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
602
- PrintCx :: with ( FmtPrinter { fmt : f } , |cx| {
595
+ PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
603
596
print ! ( cx, write( "UpvarId({:?};`{}`;{:?})" ,
604
597
self . var_path. hir_id,
605
598
cx. tcx. hir( ) . name( cx. tcx. hir( ) . hir_to_node_id( self . var_path. hir_id) ) ,
@@ -922,7 +915,7 @@ define_print! {
922
915
define_print ! {
923
916
( ) ty:: Variance , ( self , cx) {
924
917
debug {
925
- cx. printer. fmt . write_str( match * self {
918
+ cx. printer. write_str( match * self {
926
919
ty:: Covariant => "+" ,
927
920
ty:: Contravariant => "-" ,
928
921
ty:: Invariant => "o" ,
0 commit comments