@@ -1853,17 +1853,26 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
18531853 TyKind :: Array ( ty, ref length) => {
18541854 let length = match length {
18551855 hir:: ArrayLen :: Infer ( ..) => "_" . to_string ( ) ,
1856- hir:: ArrayLen :: Body ( anon_const ) => {
1856+ hir:: ArrayLen :: Body ( const_arg ) => {
18571857 // NOTE(min_const_generics): We can't use `const_eval_poly` for constants
18581858 // as we currently do not supply the parent generics to anonymous constants
18591859 // but do allow `ConstKind::Param`.
18601860 //
18611861 // `const_eval_poly` tries to first substitute generic parameters which
18621862 // results in an ICE while manually constructing the constant and using `eval`
18631863 // does nothing for `ConstKind::Param`.
1864- let ct = ty:: Const :: from_anon_const ( cx. tcx , anon_const. def_id ) ;
1865- let param_env = cx. tcx . param_env ( anon_const. def_id ) ;
1866- print_const ( cx, ct. normalize ( cx. tcx , param_env) )
1864+ let ct = ty:: Const :: from_const_arg_without_feeding ( cx. tcx , const_arg) ;
1865+ let ct = if let hir:: ConstArgKind :: Anon ( hir:: AnonConst { def_id, .. } ) =
1866+ const_arg. kind
1867+ {
1868+ // Only anon consts can implicitly capture params.
1869+ // FIXME: is this correct behavior?
1870+ let param_env = cx. tcx . param_env ( * def_id) ;
1871+ ct. normalize ( cx. tcx , param_env)
1872+ } else {
1873+ ct
1874+ } ;
1875+ print_const ( cx, ct)
18671876 }
18681877 } ;
18691878
0 commit comments