Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc ICE: "tried to calculate a disambiguator for a def without a namespace?" #85615

Closed
SergioBenitez opened this issue May 24, 2021 · 7 comments · Fixed by #87078
Closed
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@SergioBenitez
Copy link
Contributor

SergioBenitez commented May 24, 2021

Unfortunately I don't have an easy-to-repro case. This happened while working on Rocket's docs. I renamed a method which made a previously valid link invalid and I got this ICE. Fixing the doc link fixes the error. Backtrace from rustc 1.54.0-nightly (5dc8789 2021-05-21) follows:

warning: unresolved link to `Context::value`
  --> core/lib/src/form/context.rs:63:10
   |
63 | /// via [`Context::value()`] or [`Context::values()`]. Data fields do not have
   |          ^^^^^^^^^^^^^^^^^^ the struct `Context` has no function named `value`
   |
   = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

thread 'rustc' panicked at 'tried to calculate a disambiguator for a def without a namespace?', src/librustdoc/passes/collect_intra_doc_links.rs:1607:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/core/src/panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/5dc8789e300930751a78996da0fa906be5a344a2/library/core/src/option.rs:1241:5
   3: rustdoc::passes::collect_intra_doc_links::suggest_disambiguator
   4: core::ops::function::FnOnce::call_once{{vtable.shim}}
   5: rustc_middle::lint::struct_lint_level::struct_lint_level_impl
   6: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve_link::{{closure}}
   7: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve_link::{{closure}}
   8: rustdoc::passes::collect_intra_doc_links::LinkCollector::resolve_link
   9: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  10: alloc::vec::source_iter_marker::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  11: rustdoc::fold::DocFolder::fold_inner_recur
  12: rustdoc::fold::DocFolder::fold_item_recur
  13: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  14: alloc::vec::source_iter_marker::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  15: rustdoc::fold::DocFolder::fold_inner_recur
  16: rustdoc::fold::DocFolder::fold_item_recur
  17: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  18: alloc::vec::source_iter_marker::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  19: rustdoc::fold::DocFolder::fold_inner_recur
  20: rustdoc::fold::DocFolder::fold_item_recur
  21: <rustdoc::passes::collect_intra_doc_links::LinkCollector as rustdoc::fold::DocFolder>::fold_item
  22: rustdoc::passes::collect_intra_doc_links::collect_intra_doc_links
  23: rustdoc::core::run_global_ctxt
  24: rustc_interface::passes::QueryContext::enter
  25: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  26: rustc_span::with_source_map
  27: rustc_interface::interface::create_compiler_and_run
  28: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@SergioBenitez SergioBenitez added the C-bug Category: This is a bug. label May 24, 2021
@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels May 24, 2021
@jyn514
Copy link
Member

jyn514 commented May 24, 2021

If someone can compile a build of rustdoc that comments out this line:

suggest_disambiguator(resolved, diag, path_str, dox, sp, &ori_link.range);

you should get a much better error message that says exactly what went wrong (it will start with "incompatible link kind"), and that should give an idea of where the bug is.

@jyn514 jyn514 added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label May 24, 2021
@jyn514
Copy link
Member

jyn514 commented May 24, 2021

@SergioBenitez can you link to the exact commit of Rocket that caused the ICE?

@SergioBenitez
Copy link
Contributor Author

SergioBenitez commented May 24, 2021

This is the current master tip, rwf2/Rocket@ab13d73. You may be able to replicate this by referencing Context::value() in the struct's docs in core/lib/src/form/context.rs and then changing the method's name to something else. If this fails, I will try to create a reproducible case.

@jyn514 jyn514 added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Jun 21, 2021
@fee1-dead
Copy link
Member

fee1-dead commented Jul 12, 2021

warning: unresolved link to `Context::value`
  --> core/lib/src/form/context.rs:26:10
   |
26 | /// via [`Context::value()`] or [`Context::values()`]. Data fields do not have
   |          ^^^^^^^^^^^^^^^^^^ the struct `Context` has no function named `value`

warning: incompatible link kind for `Context::values`
  --> core/lib/src/form/context.rs:26:34
   |
26 | /// via [`Context::value()`] or [`Context::values()`]. Data fields do not have
   |                                  ^^^^^^^^^^^^^^^^^^^
   |
   = note: this link resolved to a field, which is not a function

MCVE:

/// [`Foo::bar()`]
pub struct Foo {
    bar: u8
}

@rustbot label -E-needs-mcve

@fee1-dead
Copy link
Member

@rustbot claim

@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2021

Error: Parsing relabel command in comment failed: ...'needs-MCVE' | error: a label delta at >| '):

'...

Please let **`@rust-lang/release`** know if you're having trouble with this bot.

@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2021

Error: Parsing relabel command in comment failed: ...'needs-mcve' | error: a label delta at >| '):

'...

Please let **`@rust-lang/release`** know if you're having trouble with this bot.

@rustbot rustbot removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jul 12, 2021
@bors bors closed this as completed in 15af98d Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants