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

thread 'rustc' panicked at 'no entry found for key', src/librustdoc/passes/collect_intra_doc_links.rs:781:16 #103463

Closed
kpreid opened this issue Oct 24, 2022 · 5 comments · Fixed by #103649
Assignees
Labels
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

@kpreid
Copy link
Contributor

kpreid commented Oct 24, 2022

Code

Cargo.toml

[dependencies]
luminance = "0.47.0"

lib.rs

use luminance::context::GraphicsContext;

Run cargo +nightly doc on this and get an ICE. Note that documenting luminance itself does not panic, and that the use is necessary.

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (7fcf850d7 2022-10-23)
binary: rustc
commit-hash: 7fcf850d7942804990a1d2e3fe036622a0fe4c74
commit-date: 2022-10-23
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2

Also reproduces on Linux (GitHub Actions) with the same nightly version.

Error output

thread 'rustc' panicked at 'no entry found for key', src/librustdoc/passes/collect_intra_doc_links.rs:781:16
Backtrace

stack backtrace:
   0:        0x10acbfad2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc249a3c8297d373c
   1:        0x10ad1782a - core::fmt::write::h1620df6049c84a8a
   2:        0x10acb1a9c - std::io::Write::write_fmt::h5f47dfe6d9626373
   3:        0x10acbf89a - std::sys_common::backtrace::print::h8ac10ae9f1f60af9
   4:        0x10acc2ca6 - std::panicking::default_hook::{{closure}}::h9e29e48aa798ad78
   5:        0x10acc29f7 - std::panicking::default_hook::h7132194e196f4b3d
   6:        0x1151f9d4d - rustc_driver[888de4bb47265800]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10acc34a1 - std::panicking::rust_panic_with_hook::h8e7115c018c00df7
   8:        0x10acc3233 - std::panicking::begin_panic_handler::{{closure}}::ha889da438f13c824
   9:        0x10acbff68 - std::sys_common::backtrace::__rust_end_short_backtrace::h731c170607da3cbe
  10:        0x10acc2efd - _rust_begin_unwind
  11:        0x10ad44293 - core::panicking::panic_fmt::h7ba977a8fb3b8591
  12:        0x10ad143ab - core::panicking::panic_display::h1228406ea053a602
  13:        0x10ad1435c - core::panicking::panic_str::h741850756884e007
  14:        0x10ad44259 - core::option::expect_failed::h627b430105f84038
  15:        0x10980dae2 - rustdoc[14cba25f54a62242]::passes::collect_intra_doc_links::resolve_associated_trait_item
  16:        0x10980c8c8 - <rustdoc[14cba25f54a62242]::passes::collect_intra_doc_links::LinkCollector>::resolve_associated_item
  17:        0x10980aa6b - <rustdoc[14cba25f54a62242]::passes::collect_intra_doc_links::LinkCollector>::resolve
  18:        0x10980f335 - <rustdoc[14cba25f54a62242]::passes::collect_intra_doc_links::LinkCollector as rustdoc[14cba25f54a62242]::visit::DocVisitor>::visit_item
  19:        0x10980931f - rustdoc[14cba25f54a62242]::passes::collect_intra_doc_links::collect_intra_doc_links
  20:        0x109882eca - <rustc_session[716ea12a8c5970d3]::session::Session>::time::<rustdoc[14cba25f54a62242]::clean::types::Crate, rustdoc[14cba25f54a62242]::core::run_global_ctxt::{closure#7}>
  21:        0x1097f3b67 - rustdoc[14cba25f54a62242]::core::run_global_ctxt
  22:        0x109883281 - <rustc_session[716ea12a8c5970d3]::session::Session>::time::<(rustdoc[14cba25f54a62242]::clean::types::Crate, rustdoc[14cba25f54a62242]::config::RenderOptions, rustdoc[14cba25f54a62242]::formats::cache::Cache), rustdoc[14cba25f54a62242]::main_args::{closure#1}::{closure#0}::{closure#1}::{closure#0}>
  23:        0x1098c3427 - <rustc_interface[d8b29599c2eaa326]::passes::QueryContext>::enter::<rustdoc[14cba25f54a62242]::main_args::{closure#1}::{closure#0}::{closure#1}, core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>>
  24:        0x1097708bf - <rustc_interface[d8b29599c2eaa326]::interface::Compiler>::enter::<rustdoc[14cba25f54a62242]::main_args::{closure#1}::{closure#0}, core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>>
  25:        0x10981e8d0 - rustc_span[d1d6f1e5b2f04214]::with_source_map::<core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>, rustc_interface[d8b29599c2eaa326]::interface::run_compiler<core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>, rustdoc[14cba25f54a62242]::main_args::{closure#1}>::{closure#0}::{closure#1}>
  26:        0x1097bf6b6 - <scoped_tls[7fa8ac740b76ff9d]::ScopedKey<rustc_span[d1d6f1e5b2f04214]::SessionGlobals>>::set::<rustc_interface[d8b29599c2eaa326]::interface::run_compiler<core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>, rustdoc[14cba25f54a62242]::main_args::{closure#1}>::{closure#0}, core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>>
  27:        0x10982e88a - std[196a9d1e434859e3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d8b29599c2eaa326]::util::run_in_thread_pool_with_globals<rustc_interface[d8b29599c2eaa326]::interface::run_compiler<core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>, rustdoc[14cba25f54a62242]::main_args::{closure#1}>::{closure#0}, core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>>
  28:        0x109930ba0 - <<std[196a9d1e434859e3]::thread::Builder>::spawn_unchecked_<rustc_interface[d8b29599c2eaa326]::util::run_in_thread_pool_with_globals<rustc_interface[d8b29599c2eaa326]::interface::run_compiler<core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>, rustdoc[14cba25f54a62242]::main_args::{closure#1}>::{closure#0}, core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e55de32fb73b0f26]::result::Result<(), rustc_errors[5dfd537642e11b91]::ErrorGuaranteed>>::{closure#1} as core[e55de32fb73b0f26]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:        0x10accc5b7 - std::sys::unix::thread::Thread::new::thread_start::h8e46437cd55f886d
  30:     0x7ff81f3a04e1 - __pthread_start

error: internal compiler error: unexpected panic

note: 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.66.0-nightly (7fcf850d7 2022-10-23) running on x86_64-apple-darwin

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

@rustbot label +T-rustdoc -T-compiler

@kpreid kpreid 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 Oct 24, 2022
@rustbot rustbot 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 Oct 24, 2022
@SarthakSingh31
Copy link
Contributor

It looks like this started after commit e426874. (#103192)

I was able to create a MCVE:

// Crate A - src/main.rs
use B::One;

fn main() {}
// Crate B - src/lib.rs
pub struct Two;

impl Two {
    pub fn new() -> Self { todo!() }
}

pub trait One {
    /// Do something with [`Two::new`]
    fn do_something(two: Two);
}
Backtrace:
 Documenting A v0.1.0 (/extra/Projects/MCVE/A)
thread 'rustc' panicked at 'no entry found for key', src/librustdoc/passes/collect_intra_doc_links.rs:781:16
stack backtrace:
   0:     0x7fbe9216c810 - std::backtrace_rs::backtrace::libunwind::trace::haefc0dd0a0a62b67
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fbe9216c810 - std::backtrace_rs::backtrace::trace_unsynchronized::h231f73070a372c1c
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fbe9216c810 - std::sys_common::backtrace::_print_fmt::haa15dcb5c660c296
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fbe9216c810 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hfcfc314fff15b0e4
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fbe921c86ce - core::fmt::write::h2e893235039ae031
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/core/src/fmt/mod.rs:1209:17
   5:     0x7fbe9215c985 - std::io::Write::write_fmt::h310687acf0f328ac
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/io/mod.rs:1682:15
   6:     0x7fbe9216c5d5 - std::sys_common::backtrace::_print::h7594904cd4694801
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fbe9216c5d5 - std::sys_common::backtrace::print::hc63fb4b3dff70d7e
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fbe9216f3df - std::panicking::default_hook::{{closure}}::h6ab59645549c33df
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/panicking.rs:267:22
   9:     0x7fbe9216f11a - std::panicking::default_hook::h9d471aa0319ef778
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/panicking.rs:286:9
  10:     0x7fbe9216fbe8 - std::panicking::rust_panic_with_hook::hedb82473dd3f5a0d
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/panicking.rs:688:13
  11:     0x7fbe9216f987 - std::panicking::begin_panic_handler::{{closure}}::h7e1d229967107c2d
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/panicking.rs:579:13
  12:     0x7fbe9216ccbc - std::sys_common::backtrace::__rust_end_short_backtrace::he5492151b8b5b3a1
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7fbe9216f6a2 - rust_begin_unwind
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/panicking.rs:575:5
  14:     0x7fbe921c50b3 - core::panicking::panic_fmt::hf762b822ffcd739c
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/core/src/panicking.rs:65:14
  15:     0x7fbe921c5201 - core::panicking::panic_display::h6b3e06ee369cb282
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/core/src/panicking.rs:139:5
  16:     0x7fbe921c51ab - core::panicking::panic_str::heaf5e09d79be0e66
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/core/src/panicking.rs:123:5
  17:     0x7fbe921c4e26 - core::option::expect_failed::h581bb50ba961001e
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/core/src/option.rs:1876:5
  18:     0x55d9648fe9d4 - rustdoc[e6b092b8ebcfcef]::passes::collect_intra_doc_links::resolve_associated_trait_item
  19:     0x55d9648fd671 - <rustdoc[e6b092b8ebcfcef]::passes::collect_intra_doc_links::LinkCollector>::resolve_associated_item
  20:     0x55d9648fb711 - <rustdoc[e6b092b8ebcfcef]::passes::collect_intra_doc_links::LinkCollector>::resolve
  21:     0x55d9649007a8 - <rustdoc[e6b092b8ebcfcef]::passes::collect_intra_doc_links::LinkCollector as rustdoc[e6b092b8ebcfcef]::visit::DocVisitor>::visit_item
  22:     0x55d9648f9ec1 - rustdoc[e6b092b8ebcfcef]::passes::collect_intra_doc_links::collect_intra_doc_links
  23:     0x55d964ae648d - <rustc_session[4ded857a98b896bc]::session::Session>::time::<rustdoc[e6b092b8ebcfcef]::clean::types::Crate, rustdoc[e6b092b8ebcfcef]::core::run_global_ctxt::{closure#7}>
  24:     0x55d9648df769 - rustdoc[e6b092b8ebcfcef]::core::run_global_ctxt
  25:     0x55d964ae6769 - <rustc_session[4ded857a98b896bc]::session::Session>::time::<(rustdoc[e6b092b8ebcfcef]::clean::types::Crate, rustdoc[e6b092b8ebcfcef]::config::RenderOptions, rustdoc[e6b092b8ebcfcef]::formats::cache::Cache), rustdoc[e6b092b8ebcfcef]::main_args::{closure#1}::{closure#0}::{closure#1}::{closure#0}>
  26:     0x55d964b25741 - <rustc_interface[a64a4e4385c65420]::passes::QueryContext>::enter::<rustdoc[e6b092b8ebcfcef]::main_args::{closure#1}::{closure#0}::{closure#1}, core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>>
  27:     0x55d964a42844 - <rustc_interface[a64a4e4385c65420]::interface::Compiler>::enter::<rustdoc[e6b092b8ebcfcef]::main_args::{closure#1}::{closure#0}, core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>>
  28:     0x55d9648bcf23 - std[aff2bf53d717ad31]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a64a4e4385c65420]::util::run_in_thread_pool_with_globals<rustc_interface[a64a4e4385c65420]::interface::run_compiler<core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>, rustdoc[e6b092b8ebcfcef]::main_args::{closure#1}>::{closure#0}, core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>>
  29:     0x55d964b9149a - <<std[aff2bf53d717ad31]::thread::Builder>::spawn_unchecked_<rustc_interface[a64a4e4385c65420]::util::run_in_thread_pool_with_globals<rustc_interface[a64a4e4385c65420]::interface::run_compiler<core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>, rustdoc[e6b092b8ebcfcef]::main_args::{closure#1}>::{closure#0}, core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1359fc6eb4466362]::result::Result<(), rustc_errors[192e0008dc26bff9]::ErrorGuaranteed>>::{closure#1} as core[1359fc6eb4466362]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7fbe921796a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h27f3134faf8b42b4
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/alloc/src/boxed.rs:1987:9
  31:     0x7fbe921796a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h46d82bf285dffad3
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/alloc/src/boxed.rs:1987:9
  32:     0x7fbe921796a3 - std::sys::unix::thread::Thread::new::thread_start::hdb1ca70a964535d0
                               at /rustc/758f19645b8ebce61ea52d1f6672fd057bc8dbee/library/std/src/sys/unix/thread.rs:108:17
  33:     0x7fbe91edc8fd - <unknown>
  34:     0x7fbe91f5ea60 - <unknown>
  35:                0x0 - <unknown>
error: could not document `A`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2021 --crate-type bin --crate-name A src/main.rs -o /extra/Projects/MCVE/A/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --document-private-items '-Arustdoc::private-intra-doc-links' -C metadata=8650d43ce013f66f -L dependency=/extra/Projects/MCVE/A/target/debug/deps --extern B=/extra/Projects/MCVE/A/target/debug/deps/libB-a432d16f3e36888e.rmeta --crate-version 0.1.0` (exit status: 101)

@GuillaumeGomez
Copy link
Member

cc @petrochenkov

@petrochenkov petrochenkov self-assigned this Oct 27, 2022
@petrochenkov
Copy link
Contributor

petrochenkov commented Oct 27, 2022

Further minimized:

pub trait Trait {
    /// [`u8::clone`]
    fn method();
}
// aux-build:issue-103463-aux.rs

extern crate issue_103463_aux;
use issue_103463_aux::Trait;

fn main() {}

The issue disappears if the private use is removed.
Looks like some logic in rustdoc is over-eager to pull in stuff through private imports, links in Trait's methods are not visible in the generated documentation and shouldn't be resolved at all.

@petrochenkov
Copy link
Contributor

resolve_use_source -> register_res -> record_extern_trait are responsible for including the trait into the rustdoc's crate representation, still unclear why.

@petrochenkov
Copy link
Contributor

Fixed in #103649.

@bors bors closed this as completed in 822f8c2 Nov 2, 2022
RalfJung pushed a commit to RalfJung/miri that referenced this issue Nov 5, 2022
rustdoc: Do not add external traits to the crate in `register_res`

It's not clear why it was done, and apparently it's no longer necessary now.
Such additions are unpredictable for early doc link resolution and would force us to collect all doc links from all external traits.

Fixes rust-lang/rust#103463
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 20, 2024
rustdoc: Do not add external traits to the crate in `register_res`

It's not clear why it was done, and apparently it's no longer necessary now.
Such additions are unpredictable for early doc link resolution and would force us to collect all doc links from all external traits.

Fixes rust-lang/rust#103463
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
rustdoc: Do not add external traits to the crate in `register_res`

It's not clear why it was done, and apparently it's no longer necessary now.
Such additions are unpredictable for early doc link resolution and would force us to collect all doc links from all external traits.

Fixes rust-lang/rust#103463
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants