Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,10 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
pub(crate) fn print_const(tcx: TyCtxt<'_>, n: ty::Const<'_>) -> String {
match n.kind() {
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args: _ }) => {
if let Some(def) = def.as_local() {
rendered_const(tcx, tcx.hir_body_owned_by(def), def)
if let Some(def) = def.as_local()
&& let Some(body_id) = tcx.hir_maybe_body_owned_by(def)
{
rendered_const(tcx, body_id, def)
} else {
inline::print_inlined_const(tcx, def)
}
Expand Down
16 changes: 16 additions & 0 deletions tests/rustdoc-ui/type-const-associated-const-no-body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/149287>
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description of what this test is checking.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, thanks!

@rustbot ready

//! Ensure that rustdoc does not ICE when a body-less type const is used
//! as an associated const.
//@ check-pass

#![feature(min_generic_const_args)]

pub trait Tr {
type const SIZE: usize;
}

fn mk_array<T: Tr>() -> [(); <T as Tr>::SIZE] {
[(); T::SIZE]
}

fn main() {}
Loading