Skip to content

rustdoc crashes when running --merge=finalize without an input crate root #146646

@EtomicBomb

Description

@EtomicBomb

Repro

WHICH_RUSTDOC=rustdoc

"$WHICH_RUSTDOC" --version

rm -rf repro
mkdir repro

# make an empty crate (the source code doesn't matter)
touch repro/base.rs 

# get doc.parts for this crate
"$WHICH_RUSTDOC" \
    --out-dir repro/doc \
    -Zunstable-options \
    --merge=none \
    --parts-out-dir repro/doc.parts/base \
    repro/base.rs

# try to run --merge=finalize without an input crate
"$WHICH_RUSTDOC" \
    --out-dir repro/merged \
    -Zunstable-options \
    --merge=finalize \
    --include-parts-dir repro/doc.parts/base

Output

rustdoc 1.92.0-nightly (a454fccb0 2025-09-15)

thread 'main' (503139) panicked at /rust/deps/scoped-tls-1.0.1/src/lib.rs:168:9:
cannot access a scoped thread local variable without calling `set` first
stack backtrace:
   0:     0x7f7af5a4bdf3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h830fbe15fbab381b
   1:     0x7f7af6201b58 - core::fmt::write::hf661a9e75db120a3
   2:     0x7f7af5a00d71 - std::io::Write::write_fmt::he76c5adbbdfd1600
   3:     0x7f7af5a11d22 - std::sys::backtrace::BacktraceLock::print::hb87325f2dc6d4dfe
   4:     0x7f7af5a17c69 - std::panicking::default_hook::{{closure}}::h5e01ba9de3335cc4
   5:     0x7f7af5a17793 - std::panicking::default_hook::h47934e1f610fefc5
   6:     0x7f7af4a08797 - std[c207121dba9f4102]::panicking::update_hook::<alloc[fbc11b1b12ed36cd]::boxed::Box<rustc_driver_impl[d9438a736
c8997f5]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f7af5a1808f - std::panicking::panic_with_hook::hfee0edaf348ac547
   8:     0x7f7af5a1763c - std::panicking::begin_panic::{{closure}}::hfab281f595fe6b8e
   9:     0x7f7af5a11e59 - std::sys::backtrace::__rust_end_short_backtrace::h18cba0a351de3087
  10:     0x7f7af3117d14 - std::panicking::begin_panic::h3e51ad6bf38ddb4a
  11:     0x7f7af63e62fd - <rustc_span[acd9e562735339de]::symbol::Symbol>::intern
  12:     0x5607faf93963 - rustdoc[de4b4e234c0ac729]::html::render::write_shared::write_rendered_cross_crate_info
  13:     0x5607faf8f90a - rustdoc[de4b4e234c0ac729]::html::render::write_shared::write_not_crate_specific
  14:     0x5607fae3f8ad - rustdoc[de4b4e234c0ac729]::main_args
  15:     0x5607fae39e34 - rustdoc[de4b4e234c0ac729]::main
  16:     0x5607fb09b943 - std[c207121dba9f4102]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  17:     0x5607fb09b959 - std[c207121dba9f4102]::rt::lang_start::<()>::{closure#0}
  18:     0x7f7af73fb8a5 - std::rt::lang_start_internal::h78f37f9ccd5c4fa5
  19:     0x5607fb09b9a8 - main
  20:     0x7f7af0c33ca8 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  21:     0x7f7af0c33d65 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:360:3
  22:     0x5607fab45ec4 - <unknown>
  23:                0x0 - <unknown>

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/ethanws/rustdoc-investigation/rustc-ice-2025-09-16T16_34_16-503139.txt` to your bu
g report

note: compiler flags: -Z unstable-options

query stack during panic:
end of query stack

Motivation

Being able to run rustdoc without an input crate root in the --merge=finalize mode is a core workflow described in RFC 3662, "This flag may be used with or without an input crate root, in which case it only links crates included via --include-parts-dir."

The commit 8511e40 seems to have introduced the call to Symbol::intern that appears in the above backtrace.

Calling rustdoc --merge=finalize with a crate root causes no crash

WHICH_RUSTDOC=rustdoc

"$WHICH_RUSTDOC" --version

rm -rf repro
mkdir repro

# make an empty crate (the source code doesn't matter)
touch repro/base.rs 

# get doc.parts for this crate
"$WHICH_RUSTDOC" \
    --out-dir repro/doc \
    -Zunstable-options \
    --merge=none \
    --parts-out-dir repro/doc.parts/base \
    repro/base.rs

# Add crate root
touch repro/input.rs

"$WHICH_RUSTDOC" \
    --out-dir repro/merged \
    -Zunstable-options \
    --merge=finalize \
    --include-parts-dir repro/doc.parts/base \
    repro/input.rs # crate root

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions