diff options
| author | Noah Lev <camelidcamel@gmail.com> | 2024-06-04 18:24:08 -0700 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2024-07-16 19:27:28 -0700 |
| commit | 67fccb70455903d05a977d83954a0f91e6f4d6e2 (patch) | |
| tree | e3210ad2e798b2e162c445fbc29e19ca39926e06 /src/librustdoc/clean | |
| parent | 8818708a317e28a2fa578d0b71640cd9865000e6 (diff) | |
| download | rust-67fccb70455903d05a977d83954a0f91e6f4d6e2.tar.gz rust-67fccb70455903d05a977d83954a0f91e6f4d6e2.zip | |
Use `ConstArg` for array lengths
Diffstat (limited to 'src/librustdoc/clean')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 6849a631010..7172f9d41cb 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1822,7 +1822,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T TyKind::Array(ty, ref length) => { let length = match length { hir::ArrayLen::Infer(..) => "_".to_string(), - hir::ArrayLen::Body(anon_const) => { + hir::ArrayLen::Body(const_arg) => { // 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`. @@ -1830,9 +1830,19 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T // `const_eval_poly` tries 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, anon_const.def_id); - let param_env = cx.tcx.param_env(anon_const.def_id); - print_const(cx, ct.normalize(cx.tcx, param_env)) + let ct = ty::Const::from_const_arg(cx.tcx, const_arg, ty::FeedConstTy::No); + #[allow(irrefutable_let_patterns)] // FIXME + let ct = if let hir::ConstArgKind::Anon(hir::AnonConst { def_id, .. }) = + const_arg.kind + { + // Only anon consts can implicitly capture params. + // FIXME: is this correct behavior? + let param_env = cx.tcx.param_env(*def_id); + ct.normalize(cx.tcx, param_env) + } else { + ct + }; + print_const(cx, ct) } }; |
