Skip to content

[ICE]: rustdoc panics when a crate glob-imports another crate that has a pub extern crate #158686

Description

@ogoffart

This is a regression in the latest nightly: cargo doc works on stable (1.95.0)
and crashes on nightly 2026-07-01.

We hit this when our CI started failing on cargo doc
(failing job).
The Slint crate depends on wgpu, and wgpu
contains pub extern crate wgpu_core as wgc;. When Slint re-exports wgpu and
rustdoc inlines that re-export, it crashes. The reduced reproducer below has no
dependency on wgpu at all.

Code

The ICE needs two crates: user depends on dep. dep re-exports another crate
with pub extern crate, and user pulls that in with a glob import. Running
cargo doc on user crashes rustdoc.

dep/lib.rs:

// Any `pub extern crate ... as ...;` triggers it. `std` keeps the repro dependency-free.
pub extern crate std as wgc;

user/lib.rs (with dep as a dependency):

pub use dep::*;

Then run:

cargo +nightly doc --no-deps -p user

Meta

rustc --version --verbose:

rustc 1.98.0-nightly (4c9d2bfe4 2026-07-01)
binary: rustc
commit-hash: 4c9d2bfe4ad7a65669098754964aaebe0ec1ced2
commit-date: 2026-07-01
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

Error output

 Documenting user v0.1.0 (/tmp/pubextern/user)

thread 'rustc' panicked at compiler/rustc_metadata/src/rmeta/decoder.rs:1404:17:
assertion `left == right` failed
  left: TypeNs("wgc")
 right: Ctor
Backtrace

thread 'rustc' panicked at /rustc/4c9d2bfe4ad7a65669098754964aaebe0ec1ced2/compiler/rustc_metadata/src/rmeta/decoder.rs:1404:17:
assertion `left == right` failed
  left: TypeNs("wgc")
 right: Ctor
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<rustc_hir::definitions::DefPathData, rustc_hir::definitions::DefPathData>
   4: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::attrs_for_def
   5: <rustc_middle::ty::context::TyCtxt>::get_all_attrs::<rustc_span::def_id::DefId>
   6: rustdoc::clean::inline::build_module_items
   7: rustdoc::clean::clean_use_statement_inner
   8: rustdoc::clean::clean_use_statement
   9: rustdoc::clean::clean_doc_module
  10: rustdoc::core::run_global_ctxt
  11: rustdoc::main_args::{closure#2}::{closure#0}
  12: rustc_interface::interface::run_compiler::<(), rustdoc::main_args::{closure#2}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

query stack during panic:
#0 [attrs_for_def] collecting attributes of `dep::wgc`
end of query stack

Likely cause

Looking at the recent history, i'd think it was introduced by #158569 (but i haven't confirmed it)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}T-compilerRelevant to the compiler 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-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions