Skip to content

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

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)

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Apr 10, 2021
  2. jyn514 commented on Apr 10, 2021

    @jyn514
    Member

    Probably a regression from #83738. You said on discord this only happens on recent nightlies, right?

  3. added
    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    and removed
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Apr 10, 2021
  4. jyn514 commented on Apr 10, 2021

    @jyn514
    Member
  5. jyn514 commented on Apr 10, 2021

    @jyn514
    Member

    searched nightlies: from nightly-2021-04-03 to nightly-2021-04-09
    regressed nightly: nightly-2021-04-04
    searched commits: from 138fd56 to 0b417ab
    regressed commit: 640ce99

    bisected with cargo-bisect-rustc v0.6.0

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --preserve --start 2021-04-03 -- doc 
  6. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Apr 10, 2021
  7. jyn514 commented on Apr 10, 2021

    @jyn514
    Member

    Rustdoc isn't stripping the backticks before loading the extern crates, this fixes the ICE:

    /// Referencing a [workspace_crate] causes an ICE.
    
  8. added
    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.
    on Apr 10, 2021
  9. jyn514 commented on Apr 10, 2021

    @jyn514
    Member

    Mentoring instructions: Change this line to delete all ` in the link.

    rust/src/librustdoc/core.rs

    Lines 373 to 375 in 4029d4d

    // FIXME: this misses a *lot* of the preprocessing done in collect_intra_doc_links
    // I think most of it shouldn't be necessary since we only need the crate prefix?
    let path_str = match Disambiguator::from_str(&link) {

  10. self-assigned this
    on Apr 10, 2021
  11. added a commit that references this issue on Apr 11, 2021
  12. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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