Skip to content

ICE assertion failed: !self.token.kind.is_close_delim_or_eof() #143351

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

macro_rules! m {
    (.$l:literal) => };

original:

macro_rules! m {
    (.$l:literal) => };


assert_eq!(nested.line(), 13); // Writing this function signature without const-forget

fn main(
        &self,
        _: std::alloc::Layout,
    ) {
    let mut x;

    if cond {
        x = &'blk [1,2,3]; //~ ERROR borrow expressions cannot be annotated with lifetimes
    }
}

Version information

rustc 1.90.0-nightly (25face980 2025-07-02)
binary: rustc
commit-hash: 25face9808491588e59b6d7844f2185b09eef479
commit-date: 2025-07-02
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7

Possibly related line of code:

}
// Consume close delimiter
self.bump();
tree
} else {
assert!(!self.token.kind.is_close_delim_or_eof());
let prev_spacing = self.token_spacing;
self.bump();
TokenTree::Token(self.prev_token, prev_spacing)
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected item, found `;`
 --> /tmp/icemaker_global_tempdir.eTdhDXKSboev/rustc_testrunner_tmpdir_reporting.9sfbgWsxPOWA/mvce.rs:2:23
  |
2 |     (.$l:literal) => };
  |                       ^
  |
  = help: macro definition declarations are not followed by a semicolon
help: remove this semicolon
  |
2 -     (.$l:literal) => };
2 +     (.$l:literal) => }
  |


thread 'rustc' panicked at compiler/rustc_parse/src/parser/mod.rs:1400:13:
assertion failed: !self.token.kind.is_close_delim_or_eof()
stack backtrace:
   0:     0x7b98a992fbd3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h53dd365cbbb15d9b
   1:     0x7b98aa002b7f - core::fmt::write::he5d2ac25265ce3f7
   2:     0x7b98a9925703 - std::io::Write::write_fmt::h55a86711f993936b
   3:     0x7b98a992fa32 - std::sys::backtrace::BacktraceLock::print::h0f1a2fc85a5204a5
   4:     0x7b98a993352a - std::panicking::default_hook::{{closure}}::h7a3895d92436dedb
   5:     0x7b98a99330af - std::panicking::default_hook::hfd199cd852b5d5be
   6:     0x7b98a89fe073 - std[b3c07c91b5987a9]::panicking::update_hook::<alloc[85efd935c50bd439]::boxed::Box<rustc_driver_impl[59dfdab74a81e7bf]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7b98a9933d7b - std::panicking::rust_panic_with_hook::hc2b67b987aefd1e3
   8:     0x7b98a9933a46 - std::panicking::begin_panic_handler::{{closure}}::hd34a90acef958d1b
   9:     0x7b98a99300a9 - std::sys::backtrace::__rust_end_short_backtrace::hb111180b2518ac00
  10:     0x7b98a993375d - __rustc[8e46c3969d69770e]::rust_begin_unwind
  11:     0x7b98a60a48f0 - core::panicking::panic_fmt::he9cd020e58e88f33
  12:     0x7b98a60ae0dc - core::panicking::panic::h4c8293b315c89a95
  13:     0x7b98aa3bf83a - <rustc_parse[abf737e3053fb975]::parser::Parser>::parse_token_tree
  14:     0x7b98aae028c4 - rustc_expand[3ad7d17b3f15a966]::mbe::macro_rules::compile_declarative_macro
  15:     0x7b98aae01e1d - <rustc_resolve[a375a8a0c6f91994]::Resolver>::compile_macro
  16:     0x7b98aa4786ea - <rustc_resolve[a375a8a0c6f91994]::def_collector::DefCollector as rustc_ast[bdd3c60d1b2d74dc]::visit::Visitor>::visit_item
  17:     0x7b98aa47777f - <rustc_resolve[a375a8a0c6f91994]::def_collector::DefCollector as rustc_ast[bdd3c60d1b2d74dc]::visit::Visitor>::visit_crate
  18:     0x7b98aa47740c - <rustc_resolve[a375a8a0c6f91994]::Resolver as rustc_expand[3ad7d17b3f15a966]::base::ResolverExpand>::visit_ast_fragment_with_placeholders
  19:     0x7b98aab4d5f7 - <rustc_expand[3ad7d17b3f15a966]::expand::MacroExpander>::collect_invocations
  20:     0x7b98ab61be46 - <rustc_expand[3ad7d17b3f15a966]::expand::MacroExpander>::fully_expand_fragment
  21:     0x7b98ab61b8f9 - <rustc_expand[3ad7d17b3f15a966]::expand::MacroExpander>::expand_crate
  22:     0x7b98aac04d1d - rustc_interface[830c764d6b1e8c47]::passes::configure_and_expand
  23:     0x7b98ab1cc4ed - rustc_interface[830c764d6b1e8c47]::passes::resolver_for_lowering_raw
  24:     0x7b98ab1cc25b - rustc_query_impl[2b3e6a4609b67a09]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b3e6a4609b67a09]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[29b7aaaec19faeee]::query::erase::Erased<[u8; 16usize]>>
  25:     0x7b98ab1cc249 - <rustc_query_impl[2b3e6a4609b67a09]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[3122e0bfb30fe198]::ops::function::FnOnce<(rustc_middle[29b7aaaec19faeee]::ty::context::TyCtxt, ())>>::call_once
  26:     0x7b98ab08b107 - rustc_query_system[3a0ce9f4b2415680]::query::plumbing::try_execute_query::<rustc_query_impl[2b3e6a4609b67a09]::DynamicConfig<rustc_query_system[3a0ce9f4b2415680]::query::caches::SingleCache<rustc_middle[29b7aaaec19faeee]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[2b3e6a4609b67a09]::plumbing::QueryCtxt, false>
  27:     0x7b98ab08ac7c - rustc_query_impl[2b3e6a4609b67a09]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7b98ab2b3180 - rustc_interface[830c764d6b1e8c47]::passes::create_and_enter_global_ctxt::<core[3122e0bfb30fe198]::option::Option<rustc_interface[830c764d6b1e8c47]::queries::Linker>, rustc_driver_impl[59dfdab74a81e7bf]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  29:     0x7b98ab263c83 - rustc_interface[830c764d6b1e8c47]::interface::run_compiler::<(), rustc_driver_impl[59dfdab74a81e7bf]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7b98ab207590 - std[b3c07c91b5987a9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[830c764d6b1e8c47]::util::run_in_thread_with_globals<rustc_interface[830c764d6b1e8c47]::util::run_in_thread_pool_with_globals<rustc_interface[830c764d6b1e8c47]::interface::run_compiler<(), rustc_driver_impl[59dfdab74a81e7bf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x7b98ab207274 - <<std[b3c07c91b5987a9]::thread::Builder>::spawn_unchecked_<rustc_interface[830c764d6b1e8c47]::util::run_in_thread_with_globals<rustc_interface[830c764d6b1e8c47]::util::run_in_thread_pool_with_globals<rustc_interface[830c764d6b1e8c47]::interface::run_compiler<(), rustc_driver_impl[59dfdab74a81e7bf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3122e0bfb30fe198]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7b98ab2058bd - std::sys::pal::unix::thread::Thread::new::thread_start::hf011d0c568e069a4
  33:     0x7b98a4c5f7eb - <unknown>
  34:     0x7b98a4ce318c - <unknown>
  35:                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: please make sure that you have updated to the latest nightly

note: rustc 1.90.0-nightly (25face980 2025-07-02) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 1 previous error


Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler 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