Skip to content

[ICE]: rustdoc: unreachable #156486

@matthiaskrgr

Description

@matthiaskrgr

Code

rustdoc -Zunstable-options --generate-macro-expansion

macro_rules! print {
    () => {
        fn printf(...);
    };
}
extern "C" {
    print! {}
}

Meta

rustc --version --verbose:

rustdoc 1.97.0-nightly (64a965e90 2026-05-11)
binary: rustdoc
commit-hash: 64a965e9013a9d14e83c4d370af26f6be6bf96fb
commit-date: 2026-05-11
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Error output

thread 'rustc' (3569203) panicked at /rustc-dev/64a965e9013a9d14e83c4d370af26f6be6bf96fb/compiler/rustc_ast_pretty/src/pprust/state.rs:1891:33:
internal error: entered unreachable code
stack backtrace:
   0:     0x7f3631497ee9 - <<std[89f22c552bc5066a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[8ad6c24798842d79]::fmt::Display>::fmt
   1:     0x7f3631c1b108 - core[8ad6c24798842d79]::fmt::write
   2:     0x7f36314aeb06 - <std[89f22c552bc5066a]::sys::stdio::unix::Stderr as std[89f22c552bc5066a]::io::Write>::write_fmt
   3:     0x7f363146df2e - std[89f22c552bc5066a]::panicking::default_hook::{closure#0}
   4:     0x7f363148b5a3 - std[89f22c552bc5066a]::panicking::default_hook
   5:     0x7f363036c511 - std[89f22c552bc5066a]::panicking::update_hook::<alloc[eb280b9ba06e18cf]::boxed::Box<rustc_driver_impl[234634a74b90a67c]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f363148b882 - std[89f22c552bc5066a]::panicking::panic_with_hook
   7:     0x7f363146e024 - std[89f22c552bc5066a]::panicking::panic_handler::{closure#0}
   8:     0x7f3631464cf9 - std[89f22c552bc5066a]::sys::backtrace::__rust_end_short_backtrace::<std[89f22c552bc5066a]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f363146fa5d - __rustc[75ff3fde40943ffb]::rust_begin_unwind
  10:     0x7f362e6fc16c - core[8ad6c24798842d79]::panicking::panic_fmt
  11:     0x7f362eaae2e2 - core[8ad6c24798842d79]::panicking::panic
  12:     0x7f36331fda4e - <rustc_ast_pretty[94499f0e95e429ed]::pprust::state::State>::print_pat
  13:     0x7f362fec80bf - rustc_ast_pretty[94499f0e95e429ed]::pprust::pat_to_string
  14:     0x55e4673f6601 - <rustdoc[d2f483044280a0b2]::html::macro_expansion::ExpandedCodeVisitor>::handle_new_span::<<rustdoc[d2f483044280a0b2]::html::macro_expansion::ExpandedCodeVisitor as rustc_ast[dbb52e5ea1070a8d]::visit::Visitor>::visit_pat::{closure#0}>
  15:     0x55e4674c2e54 - rustc_ast[dbb52e5ea1070a8d]::visit::walk_fn::<rustdoc[d2f483044280a0b2]::html::macro_expansion::ExpandedCodeVisitor>
  16:     0x55e467584fe9 - <rustc_ast[dbb52e5ea1070a8d]::ast::ItemKind as rustc_ast[dbb52e5ea1070a8d]::visit::WalkItemKind>::walk::<rustdoc[d2f483044280a0b2]::html::macro_expansion::ExpandedCodeVisitor>
  17:     0x55e46768bf0b - rustdoc[d2f483044280a0b2]::core::run_global_ctxt
  18:     0x55e4675a8371 - rustdoc[d2f483044280a0b2]::main_args::{closure#2}::{closure#0}
  19:     0x55e4675a0b2e - rustc_interface[e735d0cf28bd6984]::interface::run_compiler::<(), rustdoc[d2f483044280a0b2]::main_args::{closure#2}>::{closure#1}
  20:     0x55e4674d70e6 - std[89f22c552bc5066a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e735d0cf28bd6984]::util::run_in_thread_with_globals<rustc_interface[e735d0cf28bd6984]::util::run_in_thread_pool_with_globals<rustc_interface[e735d0cf28bd6984]::interface::run_compiler<(), rustdoc[d2f483044280a0b2]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  21:     0x55e4675e5ecd - <std[89f22c552bc5066a]::thread::lifecycle::spawn_unchecked<rustc_interface[e735d0cf28bd6984]::util::run_in_thread_with_globals<rustc_interface[e735d0cf28bd6984]::util::run_in_thread_pool_with_globals<rustc_interface[e735d0cf28bd6984]::interface::run_compiler<(), rustdoc[d2f483044280a0b2]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8ad6c24798842d79]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:     0x7f3632d3ba2c - <std[89f22c552bc5066a]::sys::thread::unix::Thread>::new::thread_start
  23:     0x7f362c49697a - <unknown>
  24:     0x7f362c51a2bc - <unknown>
  25:                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-rustdoc&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-05-12T05_48_23-3569194.txt` to your bug report

note: rustc 1.97.0-nightly (64a965e90 2026-05-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options

query stack during panic:
end of query stack
Backtrace

<backtrace>

Metadata

Metadata

Labels

C-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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions