@@ -252,6 +252,7 @@ pub trait Printer: Sized {
252
252
253
253
type Path ;
254
254
type Region ;
255
+ type Type ;
255
256
256
257
fn print_def_path (
257
258
self : PrintCx < ' _ , ' _ , ' tcx , Self > ,
@@ -278,6 +279,11 @@ pub trait Printer: Sized {
278
279
region : ty:: Region < ' _ > ,
279
280
) -> Result < Self :: Region , Self :: Error > ;
280
281
282
+ fn print_type (
283
+ self : PrintCx < ' _ , ' _ , ' tcx , Self > ,
284
+ ty : Ty < ' tcx > ,
285
+ ) -> Result < Self :: Type , Self :: Error > ;
286
+
281
287
fn path_crate (
282
288
self : PrintCx < ' _ , ' _ , ' _ , Self > ,
283
289
cnum : CrateNum ,
@@ -317,7 +323,15 @@ pub trait Printer: Sized {
317
323
}
318
324
319
325
/// Trait for printers that pretty-print using `fmt::Write` to the printer.
320
- pub trait PrettyPrinter : Printer < Error = fmt:: Error , Path = Self , Region = Self > + fmt:: Write {
326
+ pub trait PrettyPrinter :
327
+ Printer <
328
+ Error = fmt:: Error ,
329
+ Path = Self ,
330
+ Region = Self ,
331
+ Type = Self ,
332
+ > +
333
+ fmt:: Write
334
+ {
321
335
/// Enter a nested print context, for pretty-printing
322
336
/// nested components in some larger context.
323
337
fn nest < ' a , ' gcx , ' tcx , E > (
@@ -870,8 +884,8 @@ impl<'gcx, 'tcx, P: PrettyPrinter> PrintCx<'_, 'gcx, 'tcx, P> {
870
884
nest ! ( self , |cx| ty. print_display( cx) ) ;
871
885
}
872
886
UnpackedKind :: Const ( ct) => {
873
- start_or_continue ( self , start, ", " ) ?;
874
- ct. print_display ( self ) ? ;
887
+ start_or_continue ( & mut self , start, ", " ) ?;
888
+ nest ! ( self , |cx| ct. print_display( cx ) ) ;
875
889
}
876
890
}
877
891
}
@@ -901,6 +915,7 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
901
915
902
916
type Path = Self ;
903
917
type Region = Self ;
918
+ type Type = Self ;
904
919
905
920
fn print_def_path (
906
921
mut self : PrintCx < ' _ , ' _ , ' tcx , Self > ,
@@ -1031,6 +1046,13 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
1031
1046
Ok ( self . printer )
1032
1047
}
1033
1048
1049
+ fn print_type (
1050
+ self : PrintCx < ' _ , ' _ , ' tcx , Self > ,
1051
+ ty : Ty < ' tcx > ,
1052
+ ) -> Result < Self :: Type , Self :: Error > {
1053
+ self . pretty_print_type ( ty)
1054
+ }
1055
+
1034
1056
fn path_crate (
1035
1057
mut self : PrintCx < ' _ , ' _ , ' _ , Self > ,
1036
1058
cnum : CrateNum ,
0 commit comments