@@ -10,11 +10,11 @@ use crate::ty::{Param, Bound, RawPtr, Ref, Never, Tuple};
10
10
use crate :: ty:: { Closure , Generator , GeneratorWitness , Foreign , Projection , Opaque } ;
11
11
use crate :: ty:: { Placeholder , UnnormalizedProjection , Dynamic , Int , Uint , Infer } ;
12
12
use crate :: ty:: { self , ParamConst , Ty , TypeFoldable } ;
13
- use crate :: ty:: print:: { FmtPrinter , PrintCx , Print } ;
13
+ use crate :: ty:: print:: { FmtPrinter , PrettyPrinter , PrintCx , Print } ;
14
14
use crate :: mir:: interpret:: ConstValue ;
15
15
16
16
use std:: cell:: Cell ;
17
- use std:: fmt;
17
+ use std:: fmt:: { self , Write as _ } ;
18
18
use std:: iter;
19
19
use std:: usize;
20
20
@@ -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 > ] ,
@@ -409,7 +409,7 @@ impl<F: fmt::Write> PrintCx<'a, 'gcx, 'tcx, FmtPrinter<F>> {
409
409
}
410
410
411
411
fn in_binder < T > ( & mut self , value : & ty:: Binder < T > ) -> fmt:: Result
412
- where T : Print < ' tcx , FmtPrinter < F > , Output = fmt:: Result > + TypeFoldable < ' tcx >
412
+ where T : Print < ' tcx , P , Output = fmt:: Result > + TypeFoldable < ' tcx >
413
413
{
414
414
fn name_by_region_index ( index : usize ) -> InternedString {
415
415
match index {
@@ -494,13 +494,6 @@ pub fn parameterized<F: fmt::Write>(
494
494
} )
495
495
}
496
496
497
- impl < ' a , ' tcx , P , T : Print < ' tcx , P > > Print < ' tcx , P > for & ' a T {
498
- type Output = T :: Output ;
499
- fn print ( & self , cx : & mut PrintCx < ' _ , ' _ , ' tcx , P > ) -> Self :: Output {
500
- ( * self ) . print ( cx)
501
- }
502
- }
503
-
504
497
define_print ! {
505
498
( ' tcx) & ' tcx ty:: List <ty:: ExistentialPredicate <' tcx>>, ( self , cx) {
506
499
display {
@@ -581,15 +574,15 @@ impl fmt::Debug for ty::GenericParamDef {
581
574
582
575
impl fmt:: Debug for ty:: TraitDef {
583
576
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
584
- PrintCx :: with ( FmtPrinter { fmt : f } , |cx| {
577
+ PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
585
578
print ! ( cx, write( "{}" , cx. tcx. def_path_str( self . def_id) ) )
586
579
} )
587
580
}
588
581
}
589
582
590
583
impl fmt:: Debug for ty:: AdtDef {
591
584
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
592
- PrintCx :: with ( FmtPrinter { fmt : f } , |cx| {
585
+ PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
593
586
print ! ( cx, write( "{}" , cx. tcx. def_path_str( self . did) ) )
594
587
} )
595
588
}
@@ -605,7 +598,7 @@ impl<'tcx> fmt::Debug for ty::ClosureUpvar<'tcx> {
605
598
606
599
impl fmt:: Debug for ty:: UpvarId {
607
600
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
608
- PrintCx :: with ( FmtPrinter { fmt : f } , |cx| {
601
+ PrintCx :: with ( FmtPrinter { fmt : f } , |mut cx| {
609
602
print ! ( cx, write( "UpvarId({:?};`{}`;{:?})" ,
610
603
self . var_path. hir_id,
611
604
cx. tcx. hir( ) . name_by_hir_id( self . var_path. hir_id) ,
@@ -928,7 +921,7 @@ define_print! {
928
921
define_print ! {
929
922
( ) ty:: Variance , ( self , cx) {
930
923
debug {
931
- cx. printer. fmt . write_str( match * self {
924
+ cx. printer. write_str( match * self {
932
925
ty:: Covariant => "+" ,
933
926
ty:: Contravariant => "-" ,
934
927
ty:: Invariant => "o" ,
0 commit comments