Skip to content

ICE: rustdoc: body_owned_by: HirId(..) has no associated body #149287

@matthiaskrgr

Description

@matthiaskrgr

Code

//@ check-pass

#![feature(min_generic_const_args)]
#![allow(incomplete_features)]

pub trait Tr<X> {
    #[type_const]
    const SIZE: usize;
}

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

fn main() {}

Meta

rustc --version --verbose:

rustc 1.93.0-nightly (c23ed3ef2 2025-11-23)
binary: rustc
commit-hash: c23ed3ef28b3cc30658310f771ddc66e5b687cf4
commit-date: 2025-11-23
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_middle/src/hir/map.rs:271:13: body_owned_by: HirId(DefId(0:5 ~ assoc_const[46ca]::Tr::SIZE).0) (associated constant `SIZE` in Tr::SIZE) has no associated body
 --> assoc-const.rs:8:5
  |
8 |     const SIZE: usize;
  |     ^^^^^^^^^^^^^^^^^


thread 'rustc' (311726) panicked at compiler/rustc_middle/src/hir/map.rs:271:13:
Box<dyn Any>
stack backtrace:
   0:     0x7f4722e8d0c3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf60079e6fb6edce2
   1:     0x7f47236119c8 - core::fmt::write::h4556407225efd72f
   2:     0x7f4722e42bf6 - std::io::Write::write_fmt::h0ea3249f5299861b
   3:     0x7f4722e59dac - std::panicking::default_hook::{{closure}}::hdc04698b81fca7ef
   4:     0x7f4722e59903 - std::panicking::default_hook::h4ae2716da9aa0620
   5:     0x7f4721ede537 - std[ad4fd56af8a863a2]::panicking::update_hook::<alloc[689149252bbc5bc7]::boxed::Box<rustc_driver_impl[48d5ebda47e4f6c2]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f4722e5a162 - std::panicking::panic_with_hook::h32ebcbf876d2754f
   7:     0x7f4721f1ab51 - std[ad4fd56af8a863a2]::panicking::begin_panic::<rustc_errors[19ae2dbe7f4f67e7]::ExplicitBug>::{closure#0}
   8:     0x7f4721f0b476 - std[ad4fd56af8a863a2]::sys::backtrace::__rust_end_short_backtrace::<std[ad4fd56af8a863a2]::panicking::begin_panic<rustc_errors[19ae2dbe7f4f67e7]::ExplicitBug>::{closure#0}, !>
   9:     0x7f4721f0895a - std[ad4fd56af8a863a2]::panicking::begin_panic::<rustc_errors[19ae2dbe7f4f67e7]::ExplicitBug>
  10:     0x7f4721f383c1 - <rustc_errors[19ae2dbe7f4f67e7]::diagnostic::BugAbort as rustc_errors[19ae2dbe7f4f67e7]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f472247913c - <rustc_errors[19ae2dbe7f4f67e7]::DiagCtxtHandle>::span_bug::<rustc_span[dfef3532b619b891]::span_encoding::Span, alloc[689149252bbc5bc7]::string::String>
  12:     0x7f472249a526 - rustc_middle[796bb5e23d747b35]::util::bug::opt_span_bug_fmt::<rustc_span[dfef3532b619b891]::span_encoding::Span>::{closure#0}
  13:     0x7f472249a6d2 - rustc_middle[796bb5e23d747b35]::ty::context::tls::with_opt::<rustc_middle[796bb5e23d747b35]::util::bug::opt_span_bug_fmt<rustc_span[dfef3532b619b891]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f472248b83b - rustc_middle[796bb5e23d747b35]::ty::context::tls::with_context_opt::<rustc_middle[796bb5e23d747b35]::ty::context::tls::with_opt<rustc_middle[796bb5e23d747b35]::util::bug::opt_span_bug_fmt<rustc_span[dfef3532b619b891]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f4720592fe8 - rustc_middle[796bb5e23d747b35]::util::bug::span_bug_fmt::<rustc_span[dfef3532b619b891]::span_encoding::Span>
  16:     0x7f47241ac919 - <rustc_middle[796bb5e23d747b35]::ty::context::TyCtxt>::hir_body_owned_by
  17:     0x55e29d44fd1a - rustdoc[6004462a24d6e2c7]::clean::utils::print_const
  18:     0x55e29d426379 - rustdoc[6004462a24d6e2c7]::clean::clean_ty
  19:     0x55e29d40da6d - rustdoc[6004462a24d6e2c7]::clean::clean_function
  20:     0x55e29d311a2d - rustdoc[6004462a24d6e2c7]::clean::clean_maybe_renamed_item::{closure#0}
  21:     0x55e29d415715 - rustdoc[6004462a24d6e2c7]::clean::clean_doc_module
  22:     0x55e29d406961 - rustdoc[6004462a24d6e2c7]::core::run_global_ctxt
  23:     0x55e29d2fb210 - rustdoc[6004462a24d6e2c7]::main_args::{closure#2}::{closure#0}
  24:     0x55e29d2f274b - rustc_interface[b4fbb2cc6bda294c]::interface::run_compiler::<(), rustdoc[6004462a24d6e2c7]::main_args::{closure#2}>::{closure#1}
  25:     0x55e29d2433b8 - std[ad4fd56af8a863a2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b4fbb2cc6bda294c]::util::run_in_thread_with_globals<rustc_interface[b4fbb2cc6bda294c]::util::run_in_thread_pool_with_globals<rustc_interface[b4fbb2cc6bda294c]::interface::run_compiler<(), rustdoc[6004462a24d6e2c7]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x55e29d3211bd - <<std[ad4fd56af8a863a2]::thread::Builder>::spawn_unchecked_<rustc_interface[b4fbb2cc6bda294c]::util::run_in_thread_with_globals<rustc_interface[b4fbb2cc6bda294c]::util::run_in_thread_pool_with_globals<rustc_interface[b4fbb2cc6bda294c]::interface::run_compiler<(), rustdoc[6004462a24d6e2c7]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b965173db0298ed8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7f472471e46f - std::sys::thread::unix::Thread::new::thread_start::hacdf6d1111221eb3
  28:     0x7f471e0969cb - <unknown>
  29:     0x7f471e11aa0c - <unknown>
  30:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/tmp/im/rustc-ice-2025-11-24T20_22_06-311689.txt` to your bug report

query stack during panic:
end of query stack
error: aborting due to 1 previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions