File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed
test/rustdoc/const-generics Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -1364,16 +1364,16 @@ impl Clean<Type> for hir::Ty<'_> {
13641364 TyKind :: Slice ( ref ty) => Slice ( box ty. clean ( cx) ) ,
13651365 TyKind :: Array ( ref ty, ref length) => {
13661366 let def_id = cx. tcx . hir ( ) . local_def_id ( length. hir_id ) ;
1367- let length = match cx . tcx . const_eval_poly ( def_id . to_def_id ( ) ) {
1368- Ok ( length ) => {
1369- print_const ( cx , ty :: Const :: from_value ( cx . tcx , length , cx . tcx . types . usize ) )
1370- }
1371- Err ( _ ) => cx
1372- . sess ( )
1373- . source_map ( )
1374- . span_to_snippet ( cx. tcx . def_span ( def_id) )
1375- . unwrap_or_else ( |_| "_" . to_string ( ) ) ,
1376- } ;
1367+ // NOTE(min_const_generics): We can't use ` const_eval_poly` for constants
1368+ // as we currently do not supply the parent generics to anonymous constants
1369+ // but do allow `ConstKind::Param`.
1370+ //
1371+ // `const_eval_poly` tries to to first substitute generic parameters which
1372+ // results in an ICE while manually constructing the constant and using `eval`
1373+ // does nothing for `ConstKind::Param`.
1374+ let ct = ty :: Const :: from_anon_const ( cx. tcx , def_id) ;
1375+ let param_env = cx . tcx . param_env ( def_id ) ;
1376+ let length = print_const ( cx , ct . eval ( cx . tcx , param_env ) ) ;
13771377 Array ( box ty. clean ( cx) , length)
13781378 }
13791379 TyKind :: Tup ( ref tys) => Tuple ( tys. clean ( cx) ) ,
Original file line number Diff line number Diff line change 1+ // ignore-tidy-linelength
2+ #![ feature( min_const_generics) ]
3+ #![ crate_name = "foo" ]
4+
5+ // @has foo/type.CellIndex.html '//pre[@class="rust typedef"]' 'type CellIndex<const D: usize> = [i64; D];'
6+ pub type CellIndex < const D : usize > = [ i64 ; D ] ;
You can’t perform that action at this time.
0 commit comments