diff options
| author | lcnr <rust@lcnr.de> | 2021-12-23 10:01:59 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2021-12-23 10:09:35 +0100 |
| commit | 77733ba81efe77ebc557bc0ad961d90aee8facf5 (patch) | |
| tree | 29fa597ff591a6c03c52897200441a14862e715f | |
| parent | e3f5cc6c38434a7e32e2f52456b8da6eebf013de (diff) | |
fix rustdoc
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 2b4466d4041..1ebbbba541e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1335,17 +1335,23 @@ impl Clean<Type> for hir::Ty<'_> { } TyKind::Slice(ref ty) => Slice(box ty.clean(cx)), TyKind::Array(ref ty, ref length) => { - let def_id = cx.tcx.hir().local_def_id(length.hir_id); - // NOTE(min_const_generics): We can't use `const_eval_poly` for constants - // as we currently do not supply the parent generics to anonymous constants - // but do allow `ConstKind::Param`. - // - // `const_eval_poly` tries to to first substitute generic parameters which - // results in an ICE while manually constructing the constant and using `eval` - // does nothing for `ConstKind::Param`. - let ct = ty::Const::from_anon_const(cx.tcx, def_id); - let param_env = cx.tcx.param_env(def_id); - let length = print_const(cx, ct.eval(cx.tcx, param_env)); + let length = match length { + hir::ArrayLen::Infer(_, _) => "_".to_string(), + hir::ArrayLen::Body(anon_const) => { + let def_id = cx.tcx.hir().local_def_id(anon_const.hir_id); + // NOTE(min_const_generics): We can't use `const_eval_poly` for constants + // as we currently do not supply the parent generics to anonymous constants + // but do allow `ConstKind::Param`. + // + // `const_eval_poly` tries to to first substitute generic parameters which + // results in an ICE while manually constructing the constant and using `eval` + // does nothing for `ConstKind::Param`. + let ct = ty::Const::from_anon_const(cx.tcx, def_id); + let param_env = cx.tcx.param_env(def_id); + print_const(cx, ct.eval(cx.tcx, param_env)) + } + }; + Array(box ty.clean(cx), length) } TyKind::Tup(tys) => Tuple(tys.iter().map(|x| x.clean(cx)).collect()), |
