@@ -7,6 +7,7 @@ use rustc_target::abi::{HasDataLayout, Size};
77
88use crate :: mir:: interpret:: { alloc_range, AllocId , ConstAllocation , ErrorHandled , Scalar } ;
99use crate :: mir:: { pretty_print_const_value, Promoted } ;
10+ use crate :: ty:: print:: with_no_trimmed_paths;
1011use crate :: ty:: GenericArgsRef ;
1112use crate :: ty:: ScalarInt ;
1213use crate :: ty:: { self , print:: pretty_print_const, Ty , TyCtxt } ;
@@ -489,9 +490,18 @@ impl<'tcx> Display for Const<'tcx> {
489490 Const :: Ty ( c) => pretty_print_const ( c, fmt, true ) ,
490491 Const :: Val ( val, ty) => pretty_print_const_value ( val, ty, fmt) ,
491492 // FIXME(valtrees): Correctly print mir constants.
492- Const :: Unevaluated ( ..) => {
493- fmt. write_str ( "_" ) ?;
494- Ok ( ( ) )
493+ Const :: Unevaluated ( c, _ty) => {
494+ ty:: tls:: with ( move |tcx| {
495+ let c = tcx. lift ( c) . unwrap ( ) ;
496+ // Matches `GlobalId` printing.
497+ let instance =
498+ with_no_trimmed_paths ! ( tcx. def_path_str_with_args( c. def, c. args) ) ;
499+ write ! ( fmt, "{instance}" ) ?;
500+ if let Some ( promoted) = c. promoted {
501+ write ! ( fmt, "::{promoted:?}" ) ?;
502+ }
503+ Ok ( ( ) )
504+ } )
495505 }
496506 }
497507 }
0 commit comments