Skip to content

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

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

Closed
bnjbvr opened this issue May 4, 2023 · 0 comments · Fixed by #111195
Closed

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

bnjbvr opened this issue May 4, 2023 · 0 comments · Fixed by #111195
Assignees
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. 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

@bnjbvr
Copy link
Contributor

bnjbvr commented May 4, 2023

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)
@bnjbvr bnjbvr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 4, 2023
@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 4, 2023
@GuillaumeGomez GuillaumeGomez self-assigned this May 4, 2023
@jyn514 jyn514 added A-resolve Area: Name/path resolution done by `rustc_resolve` specifically A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels May 4, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 23, 2023
@bors bors closed this as completed in d69787f May 24, 2023
saethlin pushed a commit to saethlin/miri that referenced this issue May 26, 2023
…ochenkov

Prevent crash when a path is not resolved in intra-doc link

Fixes rust-lang/rust#111189.

cc `@petrochenkov`
r? `@notriddle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. 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.

3 participants