@@ -606,7 +606,7 @@ pub trait PrettyPrinter<'tcx>:
606606 ty:: Infer ( infer_ty) => {
607607 let verbose = self . tcx ( ) . sess . verbose ( ) ;
608608 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) {
610610 p ! ( write( "{}" , name) )
611611 } else {
612612 if verbose {
@@ -1015,7 +1015,11 @@ pub trait PrettyPrinter<'tcx>:
10151015 }
10161016 }
10171017
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 > {
10191023 None
10201024 }
10211025
@@ -1203,7 +1207,14 @@ pub trait PrettyPrinter<'tcx>:
12031207 }
12041208 }
12051209 }
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+ }
12071218 ty:: ConstKind :: Param ( ParamConst { name, .. } ) => p ! ( write( "{}" , name) ) ,
12081219 ty:: ConstKind :: Value ( value) => {
12091220 return self . pretty_print_const_value ( value, ct. ty ( ) , print_ty) ;
@@ -1559,7 +1570,8 @@ pub struct FmtPrinterData<'a, 'tcx, F> {
15591570
15601571 pub region_highlight_mode : RegionHighlightMode < ' tcx > ,
15611572
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 > > ,
15631575}
15641576
15651577impl < ' a , ' tcx , F > Deref for FmtPrinter < ' a , ' tcx , F > {
@@ -1588,7 +1600,8 @@ impl<'a, 'tcx, F> FmtPrinter<'a, 'tcx, F> {
15881600 binder_depth : 0 ,
15891601 printed_type_count : 0 ,
15901602 region_highlight_mode : RegionHighlightMode :: new ( tcx) ,
1591- name_resolver : None ,
1603+ ty_infer_name_resolver : None ,
1604+ const_infer_name_resolver : None ,
15921605 } ) )
15931606 }
15941607}
@@ -1843,8 +1856,12 @@ impl<'tcx, F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
18431856}
18441857
18451858impl < ' 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) )
18481865 }
18491866
18501867 fn print_value_path (
0 commit comments