Skip to content

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

Closed
@SergioBenitez

Description

@SergioBenitez
Contributor

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.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by name
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on May 24, 2021
jyn514

jyn514 commented on May 24, 2021

@jyn514
Member

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.

added
E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
on May 24, 2021
jyn514

jyn514 commented on May 24, 2021

@jyn514
Member

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

SergioBenitez

SergioBenitez commented on May 24, 2021

@SergioBenitez
ContributorAuthor

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.

added
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
on Jun 21, 2021
fee1-dead

fee1-dead commented on Jul 12, 2021

@fee1-dead
Member
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

fee1-dead commented on Jul 12, 2021

@fee1-dead
Member

@rustbot claim

rustbot

rustbot commented on Jul 12, 2021

@rustbot
Collaborator

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.

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameC-bugCategory: This is a bug.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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @SergioBenitez@jyn514@fee1-dead@rustbot

    Issue actions

      rustdoc ICE: "tried to calculate a disambiguator for a def without a namespace?" · Issue #85615 · rust-lang/rust