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

rustdoc: panic when using macro@ and ! for referencing a macro in documentation #126986

Closed
bragov4ik opened this issue Jun 26, 2024 · 2 comments · Fixed by #127016
Closed

rustdoc: panic when using macro@ and ! for referencing a macro in documentation #126986

bragov4ik opened this issue Jun 26, 2024 · 2 comments · Fixed by #127016
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. 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

@bragov4ik
Copy link

Code

//! Some module with [macro@some_cool_macro!]

macro_rules! some_cool_macro {
    () => {};
}

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

also here as a repo

Meta

Occurs on stable + nightly

rustc --version --verbose:

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: aarch64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7

rustc --version --verbose:

rustc 1.81.0-nightly (fda509e81 2024-06-25)
binary: rustc
commit-hash: fda509e817abeeecb5b76bc1de844f355675c81e
commit-date: 2024-06-25
host: aarch64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

i replaced backtrace with <attached below> for readability since it's displayed without any flags:

❯ rustdoc ./src/main.rs
error: internal compiler error: src/librustdoc/passes/collect_intra_doc_links.rs:402:17: no resolution for "some_cool_macro!" MacroNS DefId(0:0 ~ main[e129])
 --> ./src/main.rs:1:1
  |
1 | / //! Some module with [macro@some_cool_macro!]
2 | |
3 | | macro_rules! some_cool_macro {
4 | |     () => {};
... |
8 | |     println!("Hello, world!");
9 | | }
  | |_^

thread 'rustc' panicked at src/librustdoc/passes/collect_intra_doc_links.rs:402:17:
Box<dyn Any>
stack backtrace:
<attached below>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: rustc 1.79.0 (129f3b996 2024-06-10) running on aarch64-apple-darwin

query stack during panic:
end of query stack
Backtrace

stack backtrace:
   0:        0x103cc1750 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d
   1:        0x103d04470 - core::fmt::write::heedef092c8c0962e
   2:        0x103cb7a1c - std::io::Write::write_fmt::h7178e8e2ea928914
   3:        0x103cc15a8 - std::sys_common::backtrace::print::h417292deb95532ed
   4:        0x103cc3b2c - std::panicking::default_hook::{{closure}}::h0cb68f1228c4613a
   5:        0x103cc3820 - std::panicking::default_hook::h24535936bc1f51de
   6:        0x10d18f828 - <alloc[d07bc629de031c28]::boxed::Box<rustc_driver_impl[17630cf877ef70bb]::install_ice_hook::{closure#0}> as core[fca7800875c611c6]::ops::function::Fn<(&dyn for<'a, 'b> core[fca7800875c611c6]::ops::function::Fn<(&'a core[fca7800875c611c6]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[fca7800875c611c6]::marker::Sync + core[fca7800875c611c6]::marker::Send, &core[fca7800875c611c6]::panic::panic_info::PanicInfo)>>::call
   7:        0x103cc4524 - std::panicking::rust_panic_with_hook::h5db4d2345b297bed
   8:        0x10d21b198 - std[e84bc52996b8b382]::panicking::begin_panic::<rustc_errors[3520987c35dd2513]::ExplicitBug>::{closure#0}
   9:        0x10d219ce0 - std[e84bc52996b8b382]::sys_common::backtrace::__rust_end_short_backtrace::<std[e84bc52996b8b382]::panicking::begin_panic<rustc_errors[3520987c35dd2513]::ExplicitBug>::{closure#0}, !>
  10:        0x1111e7750 - std[e84bc52996b8b382]::panicking::begin_panic::<rustc_errors[3520987c35dd2513]::ExplicitBug>
  11:        0x10d21c0c0 - <rustc_errors[3520987c35dd2513]::diagnostic::BugAbort as rustc_errors[3520987c35dd2513]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x102561cc4 - <rustc_errors[3520987c35dd2513]::DiagCtxt>::span_bug::<rustc_span[984a238feadb13f5]::span_encoding::Span, alloc[d07bc629de031c28]::string::String>
  13:        0x102621300 - rustc_middle[e187904418cf7088]::util::bug::opt_span_bug_fmt::<rustc_span[984a238feadb13f5]::span_encoding::Span>::{closure#0}
  14:        0x102621334 - rustc_middle[e187904418cf7088]::ty::context::tls::with_opt::<rustc_middle[e187904418cf7088]::util::bug::opt_span_bug_fmt<rustc_span[984a238feadb13f5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:        0x10261fa58 - rustc_middle[e187904418cf7088]::ty::context::tls::with_context_opt::<rustc_middle[e187904418cf7088]::ty::context::tls::with_opt<rustc_middle[e187904418cf7088]::util::bug::opt_span_bug_fmt<rustc_span[984a238feadb13f5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:        0x1028bfc98 - rustc_middle[e187904418cf7088]::util::bug::span_bug_fmt::<rustc_span[984a238feadb13f5]::span_encoding::Span>
  17:        0x1024f1314 - <rustdoc[6f79afcbacfec209]::passes::collect_intra_doc_links::LinkCollector>::resolve_path
  18:        0x1024f1408 - <rustdoc[6f79afcbacfec209]::passes::collect_intra_doc_links::LinkCollector>::resolve
  19:        0x1024f4408 - <rustdoc[6f79afcbacfec209]::passes::collect_intra_doc_links::LinkCollector>::resolve_with_disambiguator_cached
  20:        0x1024fec68 - <rustdoc[6f79afcbacfec209]::passes::collect_intra_doc_links::LinkCollector>::resolve_links
  21:        0x1024f03e8 - rustdoc[6f79afcbacfec209]::passes::collect_intra_doc_links::collect_intra_doc_links
  22:        0x10269cffc - <rustc_session[176b2fa42c486007]::session::Session>::time::<rustdoc[6f79afcbacfec209]::clean::types::Crate, rustdoc[6f79afcbacfec209]::core::run_global_ctxt::{closure#6}>
  23:        0x10263a438 - rustdoc[6f79afcbacfec209]::core::run_global_ctxt
  24:        0x10269c4d8 - <rustc_session[176b2fa42c486007]::session::Session>::time::<core[fca7800875c611c6]::result::Result<(rustdoc[6f79afcbacfec209]::clean::types::Crate, rustdoc[6f79afcbacfec209]::config::RenderOptions, rustdoc[6f79afcbacfec209]::formats::cache::Cache), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustdoc[6f79afcbacfec209]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  25:        0x1025f99c8 - <rustc_middle[e187904418cf7088]::ty::context::GlobalCtxt>::enter::<rustdoc[6f79afcbacfec209]::main_args::{closure#1}::{closure#0}::{closure#0}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>
  26:        0x1025f4700 - rustc_span[984a238feadb13f5]::create_session_globals_then::<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustc_interface[617d4417f0fbb0b3]::util::run_in_thread_with_globals<rustc_interface[617d4417f0fbb0b3]::interface::run_compiler<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustdoc[6f79afcbacfec209]::main_args::{closure#1}>::{closure#1}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  27:        0x102595224 - std[e84bc52996b8b382]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[617d4417f0fbb0b3]::util::run_in_thread_with_globals<rustc_interface[617d4417f0fbb0b3]::interface::run_compiler<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustdoc[6f79afcbacfec209]::main_args::{closure#1}>::{closure#1}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>
  28:        0x102572a50 - <<std[e84bc52996b8b382]::thread::Builder>::spawn_unchecked_<rustc_interface[617d4417f0fbb0b3]::util::run_in_thread_with_globals<rustc_interface[617d4417f0fbb0b3]::interface::run_compiler<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustdoc[6f79afcbacfec209]::main_args::{closure#1}>::{closure#1}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#2} as core[fca7800875c611c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:        0x103cccedc - std::sys::pal::unix::thread::Thread::new::thread_start::h50a0ef5291b272f3
  30:        0x185de9034 - __pthread_joiner_wake

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: rustc 1.79.0 (129f3b996 2024-06-10) running on aarch64-apple-darwin

query stack during panic:
end of query stack

@bragov4ik bragov4ik 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 Jun 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 26, 2024
@bragov4ik
Copy link
Author

The combination of course seems invalid, but the compiler shouldn't panic, right? 👀

@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 26, 2024
bvanjoi added a commit to bvanjoi/rust that referenced this issue Jun 27, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 27, 2024
…ez,notriddle

docs: check if the disambiguator matches its suffix

Fixes rust-lang#126986

This PR makes it will not continue resolving when its disambiguator doesn't match the suffix format.
bvanjoi added a commit to bvanjoi/rust that referenced this issue Jun 28, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 28, 2024
docs: check if the disambiguator matches its suffix

Fixes rust-lang#126986

This PR makes it will not continue resolving when its disambiguator doesn't match the suffix format.
@bors bors closed this as completed in ba6fe58 Jun 29, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 29, 2024
Rollup merge of rust-lang#127016 - bvanjoi:fix-126986, r=GuillaumeGomez

docs: check if the disambiguator matches its suffix

Fixes rust-lang#126986

This PR makes it will not continue resolving when its disambiguator doesn't match the suffix format.
@bragov4ik
Copy link
Author

That was quick, thank you! 🙏

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. 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