@@ -606,7 +606,7 @@ pub trait PrettyPrinter<'tcx>:
606
606
ty:: Infer ( infer_ty) => {
607
607
let verbose = self . tcx ( ) . sess . verbose ( ) ;
608
608
if let ty:: TyVar ( ty_vid) = infer_ty {
609
- if let Some ( name) = self . infer_ty_name ( ty_vid) {
609
+ if let Some ( name) = self . ty_infer_name ( ty_vid) {
610
610
p ! ( write( "{}" , name) )
611
611
} else {
612
612
if verbose {
@@ -1015,7 +1015,11 @@ pub trait PrettyPrinter<'tcx>:
1015
1015
}
1016
1016
}
1017
1017
1018
- fn infer_ty_name ( & self , _: ty:: TyVid ) -> Option < String > {
1018
+ fn ty_infer_name ( & self , _: ty:: TyVid ) -> Option < String > {
1019
+ None
1020
+ }
1021
+
1022
+ fn const_infer_name ( & self , _: ty:: ConstVid < ' tcx > ) -> Option < String > {
1019
1023
None
1020
1024
}
1021
1025
@@ -1203,7 +1207,14 @@ pub trait PrettyPrinter<'tcx>:
1203
1207
}
1204
1208
}
1205
1209
}
1206
- ty:: ConstKind :: Infer ( ..) => print_underscore ! ( ) ,
1210
+ ty:: ConstKind :: Infer ( infer_ct) => {
1211
+ match infer_ct {
1212
+ ty:: InferConst :: Var ( ct_vid)
1213
+ if let Some ( name) = self . const_infer_name ( ct_vid) =>
1214
+ p ! ( write( "{}" , name) ) ,
1215
+ _ => print_underscore ! ( ) ,
1216
+ }
1217
+ }
1207
1218
ty:: ConstKind :: Param ( ParamConst { name, .. } ) => p ! ( write( "{}" , name) ) ,
1208
1219
ty:: ConstKind :: Value ( value) => {
1209
1220
return self . pretty_print_const_value ( value, ct. ty ( ) , print_ty) ;
@@ -1551,7 +1562,8 @@ pub struct FmtPrinterData<'a, 'tcx, F> {
1551
1562
1552
1563
pub region_highlight_mode : RegionHighlightMode < ' tcx > ,
1553
1564
1554
- pub name_resolver : Option < Box < & ' a dyn Fn ( ty:: TyVid ) -> Option < String > > > ,
1565
+ pub ty_infer_name_resolver : Option < Box < dyn Fn ( ty:: TyVid ) -> Option < String > + ' a > > ,
1566
+ pub const_infer_name_resolver : Option < Box < dyn Fn ( ty:: ConstVid < ' tcx > ) -> Option < String > + ' a > > ,
1555
1567
}
1556
1568
1557
1569
impl < ' a , ' tcx , F > Deref for FmtPrinter < ' a , ' tcx , F > {
@@ -1580,7 +1592,8 @@ impl<'a, 'tcx, F> FmtPrinter<'a, 'tcx, F> {
1580
1592
binder_depth : 0 ,
1581
1593
printed_type_count : 0 ,
1582
1594
region_highlight_mode : RegionHighlightMode :: new ( tcx) ,
1583
- name_resolver : None ,
1595
+ ty_infer_name_resolver : None ,
1596
+ const_infer_name_resolver : None ,
1584
1597
} ) )
1585
1598
}
1586
1599
}
@@ -1835,8 +1848,12 @@ impl<'tcx, F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
1835
1848
}
1836
1849
1837
1850
impl < ' tcx , F : fmt:: Write > PrettyPrinter < ' tcx > for FmtPrinter < ' _ , ' tcx , F > {
1838
- fn infer_ty_name ( & self , id : ty:: TyVid ) -> Option < String > {
1839
- self . 0 . name_resolver . as_ref ( ) . and_then ( |func| func ( id) )
1851
+ fn ty_infer_name ( & self , id : ty:: TyVid ) -> Option < String > {
1852
+ self . 0 . ty_infer_name_resolver . as_ref ( ) . and_then ( |func| func ( id) )
1853
+ }
1854
+
1855
+ fn const_infer_name ( & self , id : ty:: ConstVid < ' tcx > ) -> Option < String > {
1856
+ self . 0 . const_infer_name_resolver . as_ref ( ) . and_then ( |func| func ( id) )
1840
1857
}
1841
1858
1842
1859
fn print_value_path (
0 commit comments