@@ -2066,14 +2066,24 @@ impl Clean<Type> for hir::Ty {
2066
2066
promoted : None
2067
2067
} ;
2068
2068
let n = cx. tcx . const_eval ( param_env. and ( cid) ) . unwrap ( ) ;
2069
- let n = if let ConstVal :: Unevaluated ( def_id, _) = n. val {
2070
- if let Some ( node_id) = cx. tcx . hir . as_local_node_id ( def_id) {
2071
- print_const_expr ( cx, cx. tcx . hir . body_owned_by ( node_id) )
2072
- } else {
2073
- inline:: print_inlined_const ( cx, def_id)
2074
- }
2075
- } else {
2076
- format ! ( "{:?}" , n)
2069
+ let n = match n. val {
2070
+ ConstVal :: Unevaluated ( def_id, _) => {
2071
+ if let Some ( node_id) = cx. tcx . hir . as_local_node_id ( def_id) {
2072
+ print_const_expr ( cx, cx. tcx . hir . body_owned_by ( node_id) )
2073
+ } else {
2074
+ inline:: print_inlined_const ( cx, def_id)
2075
+ }
2076
+ } ,
2077
+ ConstVal :: Value ( val) => {
2078
+ let mut s = String :: new ( ) ;
2079
+ :: rustc:: mir:: print_miri_value ( val, n. ty , & mut s) . unwrap ( ) ;
2080
+ // array lengths are obviously usize
2081
+ if s. ends_with ( "usize" ) {
2082
+ let n = s. len ( ) - "usize" . len ( ) ;
2083
+ s. truncate ( n) ;
2084
+ }
2085
+ s
2086
+ } ,
2077
2087
} ;
2078
2088
Array ( box ty. clean ( cx) , n)
2079
2089
} ,
@@ -2199,14 +2209,24 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
2199
2209
} ;
2200
2210
n = cx. tcx . const_eval ( param_env. and ( cid) ) . unwrap ( )
2201
2211
} ;
2202
- let n = if let ConstVal :: Unevaluated ( def_id, _) = n. val {
2203
- if let Some ( node_id) = cx. tcx . hir . as_local_node_id ( def_id) {
2204
- print_const_expr ( cx, cx. tcx . hir . body_owned_by ( node_id) )
2205
- } else {
2206
- inline:: print_inlined_const ( cx, def_id)
2207
- }
2208
- } else {
2209
- format ! ( "{:?}" , n)
2212
+ let n = match n. val {
2213
+ ConstVal :: Unevaluated ( def_id, _) => {
2214
+ if let Some ( node_id) = cx. tcx . hir . as_local_node_id ( def_id) {
2215
+ print_const_expr ( cx, cx. tcx . hir . body_owned_by ( node_id) )
2216
+ } else {
2217
+ inline:: print_inlined_const ( cx, def_id)
2218
+ }
2219
+ } ,
2220
+ ConstVal :: Value ( val) => {
2221
+ let mut s = String :: new ( ) ;
2222
+ :: rustc:: mir:: print_miri_value ( val, n. ty , & mut s) . unwrap ( ) ;
2223
+ // array lengths are obviously usize
2224
+ if s. ends_with ( "usize" ) {
2225
+ let n = s. len ( ) - "usize" . len ( ) ;
2226
+ s. truncate ( n) ;
2227
+ }
2228
+ s
2229
+ } ,
2210
2230
} ;
2211
2231
Array ( box ty. clean ( cx) , n)
2212
2232
}
0 commit comments