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

ICE when documenting clap 3.2.23 (still) #108334

Closed
PatchMixolydic opened this issue Feb 22, 2023 · 7 comments · Fixed by #109266
Closed

ICE when documenting clap 3.2.23 (still) #108334

PatchMixolydic opened this issue Feb 22, 2023 · 7 comments · Fixed by #109266
Assignees
Labels
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. glacier ICE tracked in rust-lang/glacier. 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

@PatchMixolydic
Copy link
Contributor

PatchMixolydic commented Feb 22, 2023

This looks similar to #108065, but this wasn't fixed by #108129

Code

src/main.rs

fn main() {
    println!("Hello world!");
}

Cargo.toml

[package]
name = "rust-issue"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "3"
$ cargo +nightly doc

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (246eae2fa 2023-02-21)
binary: rustc
commit-hash: 246eae2fab54a5139365c4e1a08c5724fb385fbf
commit-date: 2023-02-21
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

rustdoc -Vv:

rustdoc 1.69.0-nightly (246eae2fa 2023-02-21)
binary: rustdoc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Error output

thread 'rustc' panicked at 'no resolution for "ValueEnum" MacroNS DefId(0:52 ~ clap[670b]::derive)', src/librustdoc/passes/collect_intra_doc_links.rs:391:32
Backtrace

stack backtrace:
   0:     0x7f7df396ab3a - std::backtrace_rs::backtrace::libunwind::trace::hf28dbfd50804136b
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7df396ab3a - std::backtrace_rs::backtrace::trace_unsynchronized::h62d3d75d8c6c7518
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7df396ab3a - std::sys_common::backtrace::_print_fmt::h7c65ad4db782ae35
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7df396ab3a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0591d7d923081cf4
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7df39cab0e - core::fmt::write::hd8816c33fd513dac
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f7df395afe5 - std::io::Write::write_fmt::ha970bd0663a942df
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/io/mod.rs:1684:15
   6:     0x7f7df396a905 - std::sys_common::backtrace::_print::hc1125f7df30aa8c7
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7df396a905 - std::sys_common::backtrace::print::h7c336b712f9027e7
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7df396d67f - std::panicking::default_hook::{{closure}}::h0917a311388d7814
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/panicking.rs:271:22
   9:     0x7f7df396d3bb - std::panicking::default_hook::h91db7159ba663c12
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/panicking.rs:290:9
  10:     0x7f7df6c32a05 - <rustc_driver_impl[4b64b4bc5ee8683e]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[f58ef986ec581f4d]::ops::function::FnOnce<(&core[f58ef986ec581f4d]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f7df396debd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4962fd3539ba3a02
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/alloc/src/boxed.rs:2002:9
  12:     0x7f7df396debd - std::panicking::rust_panic_with_hook::h35ca8355202430f8
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/panicking.rs:696:13
  13:     0x7f7df396dc39 - std::panicking::begin_panic_handler::{{closure}}::hc6b9b77304316297
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/panicking.rs:583:13
  14:     0x7f7df396afa6 - std::sys_common::backtrace::__rust_end_short_backtrace::h4a71907d455ad567
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f7df396d942 - rust_begin_unwind
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/panicking.rs:579:5
  16:     0x7f7df39c74b3 - core::panicking::panic_fmt::h08295fd5e9d4266f
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/core/src/panicking.rs:64:14
  17:     0x55dce0441394 - <rustdoc[94b35f38d6a94f1d]::passes::collect_intra_doc_links::LinkCollector>::resolve_path
  18:     0x55dce04414be - <rustdoc[94b35f38d6a94f1d]::passes::collect_intra_doc_links::LinkCollector>::resolve
  19:     0x55dce0445042 - <rustdoc[94b35f38d6a94f1d]::passes::collect_intra_doc_links::LinkCollector as rustdoc[94b35f38d6a94f1d]::visit::DocVisitor>::visit_item
  20:     0x55dce044e53a - <rustdoc[94b35f38d6a94f1d]::passes::collect_intra_doc_links::LinkCollector as rustdoc[94b35f38d6a94f1d]::visit::DocVisitor>::visit_inner_recur
  21:     0x55dce04488ca - <rustdoc[94b35f38d6a94f1d]::passes::collect_intra_doc_links::LinkCollector as rustdoc[94b35f38d6a94f1d]::visit::DocVisitor>::visit_item
  22:     0x55dce043fe12 - rustdoc[94b35f38d6a94f1d]::passes::collect_intra_doc_links::collect_intra_doc_links
  23:     0x55dce038905e - <rustc_session[44050795d9383a68]::session::Session>::time::<rustdoc[94b35f38d6a94f1d]::clean::types::Crate, rustdoc[94b35f38d6a94f1d]::core::run_global_ctxt::{closure#7}>
  24:     0x55dce0475757 - rustdoc[94b35f38d6a94f1d]::core::run_global_ctxt
  25:     0x55dce03892e9 - <rustc_session[44050795d9383a68]::session::Session>::time::<(rustdoc[94b35f38d6a94f1d]::clean::types::Crate, rustdoc[94b35f38d6a94f1d]::config::RenderOptions, rustdoc[94b35f38d6a94f1d]::formats::cache::Cache), rustdoc[94b35f38d6a94f1d]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  26:     0x55dce0250207 - <rustc_middle[907a58d0a040d1ca]::ty::context::GlobalCtxt>::enter::<rustdoc[94b35f38d6a94f1d]::main_args::{closure#1}::{closure#0}::{closure#0}, core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>>
  27:     0x55dce02bb920 - <rustc_interface[e197867a1d20668b]::interface::Compiler>::enter::<rustdoc[94b35f38d6a94f1d]::main_args::{closure#1}::{closure#0}, core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>>
  28:     0x55dce01ebf7b - rustc_span[8c8cf17da961254a]::with_source_map::<core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>, rustc_interface[e197867a1d20668b]::interface::run_compiler<core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>, rustdoc[94b35f38d6a94f1d]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  29:     0x55dce022e112 - <scoped_tls[d6861a481158478]::ScopedKey<rustc_span[8c8cf17da961254a]::SessionGlobals>>::set::<rustc_interface[e197867a1d20668b]::interface::run_compiler<core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>, rustdoc[94b35f38d6a94f1d]::main_args::{closure#1}>::{closure#0}, core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>>
  30:     0x55dce039a970 - std[30e2381581ca1e47]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e197867a1d20668b]::util::run_in_thread_pool_with_globals<rustc_interface[e197867a1d20668b]::interface::run_compiler<core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>, rustdoc[94b35f38d6a94f1d]::main_args::{closure#1}>::{closure#0}, core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>>
  31:     0x55dce04663ff - <<std[30e2381581ca1e47]::thread::Builder>::spawn_unchecked_<rustc_interface[e197867a1d20668b]::util::run_in_thread_pool_with_globals<rustc_interface[e197867a1d20668b]::interface::run_compiler<core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>, rustdoc[94b35f38d6a94f1d]::main_args::{closure#1}>::{closure#0}, core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f58ef986ec581f4d]::result::Result<(), rustc_errors[4094b211812344c9]::ErrorGuaranteed>>::{closure#1} as core[f58ef986ec581f4d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f7df3977d93 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h740447c4991af6d5
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/alloc/src/boxed.rs:1988:9
  33:     0x7f7df3977d93 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2d2f6f4b2902f0d3
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/alloc/src/boxed.rs:1988:9
  34:     0x7f7df3977d93 - std::sys::unix::thread::Thread::new::thread_start::h352f678abefa5ff1
                               at /rustc/246eae2fab54a5139365c4e1a08c5724fb385fbf/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f7df36a8fd4 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  36:     0x7f7df372966c - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  37:                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-nightly (246eae2fa 2023-02-21) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

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

query stack during panic:
end of query stack

@rustbot modify labels +A-resolve

@PatchMixolydic PatchMixolydic 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 Feb 22, 2023
@rustbot rustbot added the A-resolve Area: Name resolution label Feb 22, 2023
@PatchMixolydic
Copy link
Contributor Author

This ICE seems to be related to intra-doc link resolution, not standard name resolution. My bad 😅

@rustbot modify labels +A-intra-doc-links -A-resolve

@rustbot rustbot added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name and removed A-resolve Area: Name resolution labels Feb 23, 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 Feb 23, 2023
@petrochenkov petrochenkov self-assigned this Feb 23, 2023
@GuillaumeGomez
Copy link
Member

Minimum reproduction code:

// foo_1.rs
pub trait Bar {}

// lib.rs
mod foo_1;

/// Hello [`Bar`]. // crash
pub use foo_1::Bar;

@petrochenkov
Copy link
Contributor

The issue is in rustdoc, it passes a wrong parent module (crate::foo_1 instead of the root crate) when requesting resolutions for [Bar].

@petrochenkov
Copy link
Contributor

The resolution exists in rustc tables, it's just attached to crate, not crate::foo_1.

@petrochenkov
Copy link
Contributor

The issue is in rustdoc, it passes a wrong parent module

Item::item_id is currently used for determining the parent module, but it's wrong for inlined use items because for them item_id represents the target item, not the use item itself.

It looks like Item::inline_stmt_id can be used instead, I'm just not sure how consistently it's set.

@GuillaumeGomez
Copy link
Member

@petrochenkov Thanks for the information! Wanna send the fix? Otherwise I plan to do it in the next days.

@petrochenkov
Copy link
Contributor

Fixed in #109266.
The issue turned out a bit deeper than described in #108334 (comment).

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 17, 2023
rustdoc: Correctly merge import's and its target's docs in one more case

Fixes rust-lang#108334.
Fixes rust-lang#108378.
Fixes rust-lang#108658.
@bors bors closed this as completed in 0e8085a Mar 20, 2023
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 C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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