Skip to content

[ICE]: When running rustdoc #160107

Description

@ilovepi

Code

crate_a.rs

pub struct Item<B>(pub B);

pub struct Container<B>(pub B);

impl<B> Container<B> {
    pub fn get_item(&self) -> Result<Item<impl Default + std::fmt::Debug + PartialEq + '_>, ()> {
        Ok(Item(0))
    }
}

crate_b.rs

extern crate crate_a;
pub use crate_a::*;

run.sh

#!/usr/bin/env bash
set -e

RUSTC="rustc"
RUSTDOC="rustdoc"

TMP_DIR="$(mktemp -d -t rustdoc_repro_XXXXXX)"

$RUSTC --crate-type=rlib --crate-name=crate_a crate_a.rs -Cmetadata=meta_a -o "$TMP_DIR/libcrate_a.rlib"

$RUSTDOC crate_b.rs \
  --crate-type=rlib \
  --crate-name=crate_a \
  -Cmetadata=meta_b \
  --extern=crate_a="$TMP_DIR/libcrate_a.rlib" \
  --out-dir="$TMP_DIR/doc"

rustc-ice-2026-07-28T23_15_14-1510933.txt

Meta

rustc --version --verbose:

rustdoc --version --verbose
rustdoc 1.98.0-nightly (c55fad5a9 2026-06-18)
binary: rustdoc
commit-hash: c55fad5a9048ad0f7cff2a4867a297647af9392b
commit-date: 2026-06-18
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 23.0.0

Error output

thread 'rustc' (1510934) panicked at compiler/rustc_metadata/src/rmeta/decoder.rs:1398:17:
assertion `left == right` failed
  left: OpaqueTy
 right: Ctor
stack backtrace:
   0:     0x7f612813bdf8 - std[ab53626fa230f38a]::backtrace_rs::backtrace::libunwind::trace
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
   1:     0x7f612813bdf8 - std[ab53626fa230f38a]::backtrace_rs::backtrace::trace_unsynchronized::<std[ab53626fa230f38a]::sys::backtrace::_print_fmt::{closure#1}>
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
   2:     0x7f612813bdf8 - std[ab53626fa230f38a]::sys::backtrace::_print_fmt
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/sys/backtrace.rs:74:9
   3:     0x7f612813bdf8 - <<std[ab53626fa230f38a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[ee11899e83b1d2d7]::fmt::Display>::fmt
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/sys/backtrace.rs:44:26
   4:     0x7f6122a8bf3a - <core[ee11899e83b1d2d7]::fmt::rt::Argument>::fmt
                               at /b/s/w/ir/x/w/rust-rust/library/core/src/fmt/rt.rs:152:76
   5:     0x7f6122a8bf3a - core[ee11899e83b1d2d7]::fmt::write
   6:     0x7f612814cad2 - std[ab53626fa230f38a]::io::default_write_fmt::<std[ab53626fa230f38a]::sys::stdio::unix::Stderr>
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/io/mod.rs:623:11
   7:     0x7f612814cad2 - <std[ab53626fa230f38a]::sys::stdio::unix::Stderr as std[ab53626fa230f38a]::io::Write>::write_fmt
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/io/mod.rs:1727:13
   8:     0x7f612810f7f6 - <std[ab53626fa230f38a]::sys::backtrace::BacktraceLock>::print
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/sys/backtrace.rs:47:9
   9:     0x7f612810f7f6 - std[ab53626fa230f38a]::panicking::default_hook::{closure#0}
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/panicking.rs:292:27
  10:     0x7f612812ee41 - std[ab53626fa230f38a]::panicking::default_hook
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/panicking.rs:319:9
  11:     0x7f61236529fd - std[ab53626fa230f38a]::panicking::update_hook::<alloc[c1b2569c24cfe1a1]::boxed::Box<rustc_driver_impl[1ab504540eac0b3b]::install_ice_hook::{closure#1}>>::{closure#0}
  12:     0x7f612812f0f2 - <alloc[c1b2569c24cfe1a1]::boxed::Box<dyn for<'a, 'b> core[ee11899e83b1d2d7]::ops::function::Fn<(&'a std[ab53626fa230f38a]::panic::PanicHookInfo<'b>,), Output = ()> + core[ee11899e83b1d2d7]::marker::Sync + core[ee11899e83b1d2d7]::marker::Send> as core[ee11899e83b1d2d7]::ops::function::Fn<(&std[ab53626fa230f38a]::panic::PanicHookInfo,)>>::call
                               at /b/s/w/ir/x/w/rust-rust/library/alloc/src/boxed.rs:2287:9
  13:     0x7f612812f0f2 - std[ab53626fa230f38a]::panicking::panic_with_hook
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/panicking.rs:822:13
  14:     0x7f612810f8b2 - std[ab53626fa230f38a]::panicking::panic_handler::{closure#0}
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/panicking.rs:687:13
  15:     0x7f6128105ed9 - std[ab53626fa230f38a]::sys::backtrace::__rust_end_short_backtrace::<std[ab53626fa230f38a]::panicking::panic_handler::{closure#0}, !>
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/sys/backtrace.rs:182:18
  16:     0x7f6128110f8d - __rustc[f2d0d3bbd64a86a8]::rust_begin_unwind
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/panicking.rs:678:5
  17:     0x7f6122d6683c - core[ee11899e83b1d2d7]::panicking::panic_fmt
                               at /b/s/w/ir/x/w/rust-rust/library/core/src/panicking.rs:80:14
  18:     0x7f6128183093 - core[ee11899e83b1d2d7]::panicking::assert_failed_inner
                               at /b/s/w/ir/x/w/rust-rust/library/core/src/panicking.rs:439:17
  19:     0x7f6127935f0f - core[ee11899e83b1d2d7]::panicking::assert_failed::<rustc_hir[a6df33731b7cde54]::definitions::DefPathData, rustc_hir[a6df33731b7cde54]::definitions::DefPathData>
  20:     0x7f6122d2e954 - rustc_metadata[f4e2fa3d801d9e0]::rmeta::decoder::cstore_impl::provide_extern::attrs_for_def
  21:     0x7f61229674a0 - rustc_query_impl[ab30a29e4c3081f]::query_impl::attrs_for_def::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f6122965d5d - rustc_query_impl[ab30a29e4c3081f]::execution::try_execute_query::<rustc_middle[12ea5071f0106e6f]::query::caches::DefIdCache<rustc_middle[12ea5071f0106e6f]::query::erase::ErasedData<[u8; 16usize]>>, false>
  23:     0x7f6122965915 - rustc_query_impl[ab30a29e4c3081f]::query_impl::attrs_for_def::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f612305d59e - <rustc_span[37f735d4c01bddd0]::def_id::DefId as rustc_hir[a6df33731b7cde54]::attrs::HasAttrs<rustc_middle[12ea5071f0106e6f]::ty::context::TyCtxt>>::get_attrs
  25:     0x558ec3319855 - rustdoc[a6367163f4ab8a8f]::html::render::search_index::build_index::convert_render_type_id
  26:     0x558ec331965e - rustdoc[a6367163f4ab8a8f]::html::render::search_index::build_index::convert_render_type
  27:     0x558ec3319385 - rustdoc[a6367163f4ab8a8f]::html::render::search_index::build_index::convert_render_type
  28:     0x558ec3319385 - rustdoc[a6367163f4ab8a8f]::html::render::search_index::build_index::convert_render_type
  29:     0x558ec3319385 - rustdoc[a6367163f4ab8a8f]::html::render::search_index::build_index::convert_render_type
  30:     0x558ec3319385 - rustdoc[a6367163f4ab8a8f]::html::render::search_index::build_index::convert_render_type
  31:     0x558ec32fcf78 - rustdoc[a6367163f4ab8a8f]::html::render::search_index::build_index
  32:     0x558ec3302a10 - rustdoc[a6367163f4ab8a8f]::html::render::write_shared::write_shared
  33:     0x558ec325226d - <rustdoc[a6367163f4ab8a8f]::html::render::context::Context>::init
  34:     0x558ec31cd270 - rustdoc[a6367163f4ab8a8f]::main_args::{closure#2}::{closure#0}
  35:     0x558ec31c1c04 - rustc_interface[e5a84faf1e80c17e]::interface::run_compiler::<(), rustdoc[a6367163f4ab8a8f]::main_args::{closure#2}>::{closure#1}
  36:     0x558ec310cb96 - std[ab53626fa230f38a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e5a84faf1e80c17e]::util::run_in_thread_with_globals<rustc_interface[e5a84faf1e80c17e]::util::run_in_thread_pool_with_globals<rustc_interface[e5a84faf1e80c17e]::interface::run_compiler<(), rustdoc[a6367163f4ab8a8f]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x558ec31fed6d - <std[ab53626fa230f38a]::thread::lifecycle::spawn_unchecked<rustc_interface[e5a84faf1e80c17e]::util::run_in_thread_with_globals<rustc_interface[e5a84faf1e80c17e]::util::run_in_thread_pool_with_globals<rustc_interface[e5a84faf1e80c17e]::interface::run_compiler<(), rustdoc[a6367163f4ab8a8f]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ee11899e83b1d2d7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f612813920f - <alloc[c1b2569c24cfe1a1]::boxed::Box<dyn core[ee11899e83b1d2d7]::ops::function::FnOnce<(), Output = ()> + core[ee11899e83b1d2d7]::marker::Send> as core[ee11899e83b1d2d7]::ops::function::FnOnce<()>>::call_once
                               at /b/s/w/ir/x/w/rust-rust/library/alloc/src/boxed.rs:2273:9
  39:     0x7f612813920f - <std[ab53626fa230f38a]::sys::thread::unix::Thread>::new::thread_start
                               at /b/s/w/ir/x/w/rust-rust/library/std/src/sys/thread/unix.rs:118:17
  40:     0x7f611f89de69 - start_thread
                               at ./nptl/pthread_create.c:448:8
  41:     0x7f611f91ce48 - __GI___clone3
                               at /build/reproducible-path/glibc-2.42/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0

error: the compiler unexpectedly panicked. This is a bug

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 `/usr/local/google/home/paulkirth/fuchsia/repro/rustc-ice-2026-07-28T23_15_14-1510933.txt` to your bug report

note: rustc 1.98.0-nightly (c55fad5a9 2026-06-18) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type rlib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [attrs_for_def] collecting attributes of `crate_a::Container<B>::get_item::{opaque#0}`
end of query stack

We ran into this in Fuchsia (https://fxbug.dev/539676977), and I was able to minimize the case down to something very small. I haven't looked closely as to why this happens. I suspect something about the crate name, but I'm not really sure, as I'm not too familiar with rmeta lookups or rustdoc internals. In any case, this feels like something that shouldn't panic or crash the tool, even if its in some bad or invalid state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions