@@ -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) ;
@@ -1559,7 +1570,8 @@ pub struct FmtPrinterData<'a, 'tcx, F> {
1559
1570
1560
1571
pub region_highlight_mode : RegionHighlightMode < ' tcx > ,
1561
1572
1562
- pub name_resolver : Option < Box < & ' a dyn Fn ( ty:: TyVid ) -> Option < String > > > ,
1573
+ pub ty_infer_name_resolver : Option < Box < dyn Fn ( ty:: TyVid ) -> Option < String > + ' a > > ,
1574
+ pub const_infer_name_resolver : Option < Box < dyn Fn ( ty:: ConstVid < ' tcx > ) -> Option < String > + ' a > > ,
1563
1575
}
1564
1576
1565
1577
impl < ' a , ' tcx , F > Deref for FmtPrinter < ' a , ' tcx , F > {
@@ -1588,7 +1600,8 @@ impl<'a, 'tcx, F> FmtPrinter<'a, 'tcx, F> {
1588
1600
binder_depth : 0 ,
1589
1601
printed_type_count : 0 ,
1590
1602
region_highlight_mode : RegionHighlightMode :: new ( tcx) ,
1591
- name_resolver : None ,
1603
+ ty_infer_name_resolver : None ,
1604
+ const_infer_name_resolver : None ,
1592
1605
} ) )
1593
1606
}
1594
1607
}
@@ -1843,8 +1856,12 @@ impl<'tcx, F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
1843
1856
}
1844
1857
1845
1858
impl < ' tcx , F : fmt:: Write > PrettyPrinter < ' tcx > for FmtPrinter < ' _ , ' tcx , F > {
1846
- fn infer_ty_name ( & self , id : ty:: TyVid ) -> Option < String > {
1847
- self . 0 . name_resolver . as_ref ( ) . and_then ( |func| func ( id) )
1859
+ fn ty_infer_name ( & self , id : ty:: TyVid ) -> Option < String > {
1860
+ self . 0 . ty_infer_name_resolver . as_ref ( ) . and_then ( |func| func ( id) )
1861
+ }
1862
+
1863
+ fn const_infer_name ( & self , id : ty:: ConstVid < ' tcx > ) -> Option < String > {
1864
+ self . 0 . const_infer_name_resolver . as_ref ( ) . and_then ( |func| func ( id) )
1848
1865
}
1849
1866
1850
1867
fn print_value_path (
0 commit comments