Skip to content

ICE: exit_elem called on empty class stack #148184

@dtolnay

Description

@dtolnay
  • src/lib.rs:

    //
    #[repro_macro::repro]
    struct Repro;
  • Cargo.toml:

    [package]
    name = "repro"
    edition = "2024"
    publish = false
    
    [dependencies]
    repro-macro = { path = "macro" }
  • macro/src/lib.rs

    use proc_macro::TokenStream;
    
    #[proc_macro_attribute]
    pub fn repro(_args: TokenStream, _input: TokenStream) -> TokenStream {
        "struct Repro;".parse().unwrap()
    }
  • macro/Cargo.toml:

    [package]
    name = "repro-macro"
    edition = "2024"
    publish = false
    
    [lib]
    proc-macro = true

cargo +nightly-2025-10-27 rustdoc --config='build.rustdocflags=["-Zunstable-options", "--generate-macro-expansion"]'

   Compiling repro-macro v0.0.0
 Documenting repro v0.0.0

thread 'rustc' (46818762) panicked at src/librustdoc/html/highlight.rs:225:42:
`exit_elem` called on empty class stack
stack backtrace:
   0:        0x111b5a1b0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h972240fd8fddf0c5
   1:        0x10efb4a70 - core::fmt::write::hc4ce1a4f9b0fe243
   2:        0x111b13234 - std::io::Write::write_fmt::h9dedd414d5aa6d6f
   3:        0x111b253f4 - std::sys::backtrace::BacktraceLock::print::h6f19f5fdf018e813
   4:        0x111b2bc8c - std::panicking::default_hook::{{closure}}::hf3816f6c1dc2ed6e
   5:        0x111b2b92c - std::panicking::default_hook::h2c3b716c7f908774
   6:        0x10fb5b6f8 - std[afe20e252829660a]::panicking::update_hook::<alloc[bc36f07fd14ea406]::boxed::Box<rustc_driver_impl[36bd8496901014dd]::install_ice_hook::{closure#1}>>::{closure#0}
   7:        0x111b2c1b4 - std::panicking::panic_with_hook::h3dcc4d4095ad556a
   8:        0x111b2be64 - std::panicking::panic_handler::{{closure}}::hf8946771d264106d
   9:        0x111b25500 - std::sys::backtrace::__rust_end_short_backtrace::h7592b2729510c7e3
  10:        0x111b099bc - __rustc[4463466e04a8a971]::rust_begin_unwind
  11:        0x114892e20 - core::panicking::panic_fmt::h22b49dfc784232b7
  12:        0x11489252c - core::option::expect_failed::h9bccb119ce1d83cb
  13:        0x102db63d0 - rustdoc[63b0dfff8c6fb358]::html::highlight::write_code::<core[d3311d316bb0ed79]::fmt::Formatter>::{closure#2}
  14:        0x102e716b0 - <rustdoc[63b0dfff8c6fb358]::html::highlight::Classifier>::advance
  15:        0x102e720a0 - <rustdoc[63b0dfff8c6fb358]::html::highlight::Classifier>::highlight
  16:        0x102d1c980 - rustdoc[63b0dfff8c6fb358]::html::highlight::write_code::<core[d3311d316bb0ed79]::fmt::Formatter>
  17:        0x102f4c8b8 - <&core[d3311d316bb0ed79]::fmt::builders::FromFn<rustdoc[63b0dfff8c6fb358]::html::sources::print_src<&mut core[d3311d316bb0ed79]::fmt::Formatter>::{closure#0}> as core[d3311d316bb0ed79]::fmt::Display>::fmt
  18:        0x10efb4a70 - core::fmt::write::hc4ce1a4f9b0fe243
  19:        0x102f4ce0c - <&askama[22502a62a6e0aee7]::filters::escape::Safe<&core[d3311d316bb0ed79]::fmt::builders::FromFn<rustdoc[63b0dfff8c6fb358]::html::sources::print_src<&mut core[d3311d316bb0ed79]::fmt::Formatter>::{closure#0}>> as core[d3311d316bb0ed79]::fmt::Display>::fmt
  20:        0x10efb4a70 - core::fmt::write::hc4ce1a4f9b0fe243
  21:        0x102f19a90 - <rustdoc[63b0dfff8c6fb358]::html::sources::SourceCollector as rustdoc[63b0dfff8c6fb358]::visit::DocVisitor>::visit_item
  22:        0x102e219d8 - <rustdoc[63b0dfff8c6fb358]::html::render::context::Context>::init
  23:        0x102dbb028 - rustdoc[63b0dfff8c6fb358]::main_args::{closure#2}::{closure#0}
  24:        0x102db0944 - rustc_interface[4b3a661e2b8d05a6]::interface::run_compiler::<(), rustdoc[63b0dfff8c6fb358]::main_args::{closure#2}>::{closure#1}
  25:        0x102d2311c - std[afe20e252829660a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4b3a661e2b8d05a6]::util::run_in_thread_with_globals<rustc_interface[4b3a661e2b8d05a6]::util::run_in_thread_pool_with_globals<rustc_interface[4b3a661e2b8d05a6]::interface::run_compiler<(), rustdoc[63b0dfff8c6fb358]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:        0x102dd8b3c - <<std[afe20e252829660a]::thread::Builder>::spawn_unchecked_<rustc_interface[4b3a661e2b8d05a6]::util::run_in_thread_with_globals<rustc_interface[4b3a661e2b8d05a6]::util::run_in_thread_pool_with_globals<rustc_interface[4b3a661e2b8d05a6]::interface::run_compiler<(), rustdoc[63b0dfff8c6fb358]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d3311d316bb0ed79]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:        0x111b21fdc - std::sys::thread::unix::Thread::new::thread_start::h41048f3b076e32d9
  28:        0x18a4abbc8 - __pthread_cond_wait

error: the compiler unexpectedly panicked. this is a bug.

note: compiler flags: --crate-type lib -Z unstable-options

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

query stack during panic:
end of query stack
error: could not document `repro`

Bisects to #146992. @GuillaumeGomez @yotamofek @lolbinarycat

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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions