Skip to content

Rustdoc crash: no resolution for "rustfmt" TypeNS DefId(0:0 ~ bb[cfb9]) #111189

Closed
@bnjbvr

Description

@bnjbvr

Using cargo 1.71.0-nightly (ac8401032 2023-05-02) or cargo 1.69.0 (6e9a83356 2023-04-12), I get a crash when trying to generate documentation from this excerpt of the Matrix Rust SDK:

Code

struct Example {}

enum CryptoStoreError {}

struct RoomSettings {}

impl Example {
    /// Get the stored room settings, such as the encryption algorithm or
    /// whether to encrypt only for trusted devices.
    ///
    /// #[rustfmt::skip]
    /// These settings can be modified via
    /// [set_room_algorithm()](#method.set_room_algorithm) and
    /// [set_room_only_allow_trusted_devices()](#method.
    /// set_room_only_allow_trusted_devices) methods.
    pub fn get_room_settings(
        &self,
        _room_id: String,
    ) -> Result<Option<RoomSettings>, CryptoStoreError> {
        Ok(None)
    }

    fn set_room_only_allow_trusted_devices(&self) {}
}

fn main() {
    let e = Example {};
    let _ = e.get_room_settings(String::new());
}

Error output

Backtrace
 Documenting bb v0.1.0 (/tmp/bb)
thread 'rustc' panicked at 'no resolution for "rustfmt" TypeNS DefId(0:0 ~ bb[cfb9])', src/librustdoc/passes/collect_intra_doc_links.rs:391:32
stack backtrace:
   0:     0x7f61fbb6731a - std::backtrace_rs::backtrace::libunwind::trace::ha9053a9a07ca49cb
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f61fbb6731a - std::backtrace_rs::backtrace::trace_unsynchronized::h9c2852a457ad564e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f61fbb6731a - std::sys_common::backtrace::_print_fmt::h457936fbfaa0070f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f61fbb6731a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5779d7bf7f70cb0c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f61fbbcab6e - core::fmt::write::h5a4baaff1bcd3eb5
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f61fbb5a2c5 - std::io::Write::write_fmt::h4bc1f301cb9e9cce
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/io/mod.rs:1684:15
   6:     0x7f61fbb670e5 - std::sys_common::backtrace::_print::h5fcdc36060f177e8
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f61fbb670e5 - std::sys_common::backtrace::print::h54ca9458b876c8bf
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f61fbb69e5f - std::panicking::default_hook::{{closure}}::hbe471161c7664ed6
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:271:22
   9:     0x7f61fbb69b9b - std::panicking::default_hook::ha3500da57aa4ac4f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:290:9
  10:     0x7f61fedcb8b5 - <rustc_driver_impl[fb92b3e21ac03dce]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[911a585bea10363d]::ops::function::FnOnce<(&core[911a585bea10363d]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f61fbb6a69d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6507bddc3eebb4a5
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:2001:9
  12:     0x7f61fbb6a69d - std::panicking::rust_panic_with_hook::h50c09d000dc561d2
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:696:13
  13:     0x7f61fbb6a419 - std::panicking::begin_panic_handler::{{closure}}::h9e2b2176e00e0d9c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:583:13
  14:     0x7f61fbb67786 - std::sys_common::backtrace::__rust_end_short_backtrace::h5739b8e512c09d02
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f61fbb6a122 - rust_begin_unwind
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5
  16:     0x7f61fbbc6ec3 - core::panicking::panic_fmt::hf33a1475b4dc5c3e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14
  17:     0x55cc3995a624 - <rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::LinkCollector>::resolve_path
  18:     0x55cc3995ac71 - <rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::LinkCollector>::resolve
  19:     0x55cc3995e715 - <rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::LinkCollector as rustdoc[483c6e22976f34cb]::visit::DocVisitor>::visit_item
  20:     0x55cc399676fa - <rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::LinkCollector as rustdoc[483c6e22976f34cb]::visit::DocVisitor>::visit_inner_recur
  21:     0x55cc39961a98 - <rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::LinkCollector as rustdoc[483c6e22976f34cb]::visit::DocVisitor>::visit_item
  22:     0x55cc3996767a - <rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::LinkCollector as rustdoc[483c6e22976f34cb]::visit::DocVisitor>::visit_inner_recur
  23:     0x55cc39961a7c - <rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::LinkCollector as rustdoc[483c6e22976f34cb]::visit::DocVisitor>::visit_item
  24:     0x55cc399590a2 - rustdoc[483c6e22976f34cb]::passes::collect_intra_doc_links::collect_intra_doc_links
  25:     0x55cc398a132e - <rustc_session[b87ece769e9b9511]::session::Session>::time::<rustdoc[483c6e22976f34cb]::clean::types::Crate, rustdoc[483c6e22976f34cb]::core::run_global_ctxt::{closure#7}>
  26:     0x55cc399ccdd0 - rustdoc[483c6e22976f34cb]::core::run_global_ctxt
  27:     0x55cc398a15b9 - <rustc_session[b87ece769e9b9511]::session::Session>::time::<(rustdoc[483c6e22976f34cb]::clean::types::Crate, rustdoc[483c6e22976f34cb]::config::RenderOptions, rustdoc[483c6e22976f34cb]::formats::cache::Cache), rustdoc[483c6e22976f34cb]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  28:     0x55cc3979fd57 - <rustc_middle[1a4ce3311a146f18]::ty::context::GlobalCtxt>::enter::<rustdoc[483c6e22976f34cb]::main_args::{closure#1}::{closure#0}::{closure#0}, core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>>
  29:     0x55cc3980afce - rustc_span[fab0eb11f1fed58d]::with_source_map::<core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>, rustc_interface[bd8390756bd7a52a]::interface::run_compiler<core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>, rustdoc[483c6e22976f34cb]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  30:     0x55cc3977d474 - <scoped_tls[473f62cd2eff9842]::ScopedKey<rustc_span[fab0eb11f1fed58d]::SessionGlobals>>::set::<rustc_interface[bd8390756bd7a52a]::interface::run_compiler<core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>, rustdoc[483c6e22976f34cb]::main_args::{closure#1}>::{closure#0}, core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>>
  31:     0x55cc398b89a0 - std[685882fd5f6d52e5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[bd8390756bd7a52a]::util::run_in_thread_pool_with_globals<rustc_interface[bd8390756bd7a52a]::interface::run_compiler<core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>, rustdoc[483c6e22976f34cb]::main_args::{closure#1}>::{closure#0}, core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>>
  32:     0x55cc399831dd - <<std[685882fd5f6d52e5]::thread::Builder>::spawn_unchecked_<rustc_interface[bd8390756bd7a52a]::util::run_in_thread_pool_with_globals<rustc_interface[bd8390756bd7a52a]::interface::run_compiler<core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>, rustdoc[483c6e22976f34cb]::main_args::{closure#1}>::{closure#0}, core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[911a585bea10363d]::result::Result<(), rustc_span[fab0eb11f1fed58d]::ErrorGuaranteed>>::{closure#1} as core[911a585bea10363d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f61fbb74593 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h39990b24eedef2ab
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:1987:9
  34:     0x7f61fbb74593 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h01a027258444143b
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:1987:9
  35:     0x7f61fbb74593 - std::sys::unix::thread::Thread::new::thread_start::ha4f1cdd9c25884ba
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys/unix/thread.rs:108:17
  36:     0x7f61fb906bb5 - <unknown>
  37:     0x7f61fb988d90 - <unknown>
  38:                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-compiler&template=ice.md

note: rustc 1.69.0 (84c898d65 2023-04-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not document `bb`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2021 --crate-type bin --crate-name bb src/main.rs -o /tmp/bb/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=79 --document-private-items '-Arustdoc::private-intra-doc-links' -C metadata=f4d133f1719d28d5 -L dependency=/tmp/bb/target/debug/deps --crate-version 0.1.0` (exit status: 101)

Metadata

Metadata

Labels

A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions