Skip to content

Rustdoc ICE: Referencing a workspace crate's root in an intra-doc link triggers an ICE #84046

@ThePuzzlemaker

Description

@ThePuzzlemaker

Code

The MCVE includes multiple crates so I've put it on a GitHub repo.

The command used for Rustdoc is just cargo +nightly doc.

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (dae9d6ac3 2021-04-09)
binary: rustc
commit-hash: dae9d6ac3e9a8fb389cfe471b30f4d72c3122196
commit-date: 2021-04-09
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

 Documenting rustdoc_ice_mcve v0.1.0 (/home/USER/Code/Rust/foo)
thread 'rustc' panicked at 'index out of bounds: the len is 18 but the index is 18', compiler/rustc_metadata/src/creader.rs:137:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: 'crate-version'

error: could not document `rustdoc_ice_mcve`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_ice_mcve src/lib.rs -o /home/USER/Code/Rust/foo/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/USER/Code/Rust/foo/target/debug/deps --extern workspace_crate=/home/USER/Code/Rust/foo/target/debug/deps/libworkspace_crate-46c87e60a6b67395.rmeta --crate-version 0.1.0` (exit status: 1)
Backtrace

I've included the backtrace with `--verbose` as it mentioned `--crate-version`.

       Fresh workspace_crate v0.1.0 (/home/USER/Code/Rust/foo/workspace_crate)
 Documenting rustdoc_ice_mcve v0.1.0 (/home/USER/Code/Rust/foo)
     Running `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_ice_mcve src/lib.rs -o /home/USER/Code/Rust/foo/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/USER/Code/Rust/foo/target/debug/deps --extern workspace_crate=/home/USER/Code/Rust/foo/target/debug/deps/libworkspace_crate-46c87e60a6b67395.rmeta --crate-version 0.1.0`
thread 'rustc' panicked at 'index out of bounds: the len is 18 but the index is 18', compiler/rustc_metadata/src/creader.rs:137:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/dae9d6ac3e9a8fb389cfe471b30f4d72c3122196/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/dae9d6ac3e9a8fb389cfe471b30f4d72c3122196/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/dae9d6ac3e9a8fb389cfe471b30f4d72c3122196/library/core/src/panicking.rs:69:5
   3: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::crate_name
   4: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   5: rustc_data_structures::stack::ensure_sufficient_stack
   6: rustc_query_system::query::plumbing::force_query_with_job
   7: rustc_query_system::query::plumbing::get_query_impl
   8: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::crate_name
   9: rustdoc::clean::inline::record_extern_fqn
  10: rustdoc::clean::utils::register_res
  11: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve_link
  12: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  13: alloc::vec::source_iter_marker::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  14: rustdoc::fold::DocFolder::fold_inner_recur
  15: rustdoc::fold::DocFolder::fold_item_recur
  16: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  17: rustdoc::passes::collect_intra_doc_links::collect_intra_doc_links
  18: rustdoc::core::run_global_ctxt
  19: rustc_interface::passes::QueryContext::enter
  20: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  21: rustc_span::with_source_map
  22: rustc_interface::interface::create_compiler_and_run
  23: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

error: Unrecognized option: 'crate-version'

error: could not document `rustdoc_ice_mcve`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name rustdoc_ice_mcve src/lib.rs -o /home/USER/Code/Rust/foo/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/USER/Code/Rust/foo/target/debug/deps --extern workspace_crate=/home/USER/Code/Rust/foo/target/debug/deps/libworkspace_crate-46c87e60a6b67395.rmeta --crate-version 0.1.0` (exit status: 1)

Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions