Skip to content

[ICE]: missing tokens for node #155333

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn main() {
    macro_rules! m {
        ($g : guard) => {
            m!($g)
        };
    }
    m !(if x)
}

original:

#![feature(macro_guard_matcher)]
fn main() {
    macro_rules! m {
        ($g : guard) => {
            m!($g)
        };
    }
    m !(if x)
}

Version information

rustc 1.97.0-nightly (bd1e7c794 2026-04-15)
binary: rustc
commit-hash: bd1e7c79485d6a4113bb11dd98cb8b415cd4a55e
commit-date: 2026-04-15
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2

Possibly related line of code:

/// `Spacing::Alone`.
pub fn token_alone(kind: TokenKind, span: Span) -> TokenStream {
TokenStream::new(vec![TokenTree::token_alone(kind, span)])
}
pub fn from_ast(node: &(impl HasAttrs + HasTokens + fmt::Debug)) -> TokenStream {
let tokens = node.tokens().unwrap_or_else(|| panic!("missing tokens for node: {:?}", node));
let mut tts = vec![];
attrs_and_tokens_to_token_trees(node.attrs(), tokens, &mut tts);
TokenStream::new(tts)
}
// If `vec` is not empty, try to glue `tt` onto its last token. The return

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

Program output

error[E0658]: `guard` fragments in macro are unstable
 --> /tmp/icemaker_global_tempdir.kseR1I47vv8o/rustc_testrunner_tmpdir_reporting.JrF9cRipeMoL/mvce.rs:3:10
  |
3 |         ($g : guard) => {
  |          ^^^^^^^^^^
  |
  = note: see issue #153104 <https://github.com/rust-lang/rust/issues/153104> for more information
  = help: add `#![feature(macro_guard_matcher)]` to the crate attributes to enable
  = note: this compiler was built on 2026-04-15; consider upgrading it if it is out of date


thread 'rustc' (1298682) panicked at /rustc-dev/bd1e7c79485d6a4113bb11dd98cb8b415cd4a55e/compiler/rustc_ast/src/tokenstream.rs:638:54:
missing tokens for node: Expr { id: NodeId(4294967040), kind: Path(None, Path { span: /tmp/icemaker_global_tempdir.kseR1I47vv8o/rustc_testrunner_tmpdir_reporting.JrF9cRipeMoL/mvce.rs:7:12: 7:13 (#0), segments: [PathSegment { ident: x#0, id: NodeId(4294967040), args: None }], tokens: None }), span: /tmp/icemaker_global_tempdir.kseR1I47vv8o/rustc_testrunner_tmpdir_reporting.JrF9cRipeMoL/mvce.rs:7:12: 7:13 (#0), attrs: [], tokens: None }
stack backtrace:
   0:     0x7f41b0024b7b - <<std[c5ab73980a16b942]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a93ae171b9b17a3a]::fmt::Display>::fmt
   1:     0x7f41b0621448 - core[a93ae171b9b17a3a]::fmt::write
   2:     0x7f41b003be46 - <std[c5ab73980a16b942]::sys::stdio::unix::Stderr as std[c5ab73980a16b942]::io::Write>::write_fmt
   3:     0x7f41afffae78 - std[c5ab73980a16b942]::panicking::default_hook::{closure#0}
   4:     0x7f41b00181e3 - std[c5ab73980a16b942]::panicking::default_hook
   5:     0x7f41aeff0a0c - std[c5ab73980a16b942]::panicking::update_hook::<alloc[73519e9f23c77201]::boxed::Box<rustc_driver_impl[733b6e0b8e0e976b]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f41b00184c2 - std[c5ab73980a16b942]::panicking::panic_with_hook
   7:     0x7f41afffaf38 - std[c5ab73980a16b942]::panicking::panic_handler::{closure#0}
   8:     0x7f41afff1c79 - std[c5ab73980a16b942]::sys::backtrace::__rust_end_short_backtrace::<std[c5ab73980a16b942]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f41afffc99d - __rustc[2880848b2880f319]::rust_begin_unwind
  10:     0x7f41acb4d3bc - core[a93ae171b9b17a3a]::panicking::panic_fmt
  11:     0x7f41b1bdbbc1 - <rustc_expand[144a5cb01134d204]::expand::MacroExpander>::fully_expand_fragment
  12:     0x7f41b1b9631d - <rustc_expand[144a5cb01134d204]::expand::MacroExpander>::expand_crate
  13:     0x7f41b0de818d - rustc_interface[9d19a1b9741214bc]::passes::resolver_for_lowering_raw
  14:     0x7f41b0de75d3 - rustc_query_impl[3291eb9cebafb6fd]::query_impl::resolver_for_lowering_raw::invoke_provider_fn::__rust_begin_short_backtrace
  15:     0x7f41b1771f26 - rustc_query_impl[3291eb9cebafb6fd]::execution::try_execute_query::<rustc_middle[9abe997593166c8f]::query::caches::SingleCache<rustc_middle[9abe997593166c8f]::query::erase::ErasedData<[u8; 16usize]>>, false>
  16:     0x7f41b1754444 - rustc_query_impl[3291eb9cebafb6fd]::query_impl::resolver_for_lowering_raw::execute_query_non_incr::__rust_end_short_backtrace
  17:     0x7f41b175226c - rustc_interface[9d19a1b9741214bc]::interface::run_compiler::<(), rustc_driver_impl[733b6e0b8e0e976b]::run_compiler::{closure#0}>::{closure#1}
  18:     0x7f41b17395be - std[c5ab73980a16b942]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9d19a1b9741214bc]::util::run_in_thread_with_globals<rustc_interface[9d19a1b9741214bc]::util::run_in_thread_pool_with_globals<rustc_interface[9d19a1b9741214bc]::interface::run_compiler<(), rustc_driver_impl[733b6e0b8e0e976b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  19:     0x7f41b1739e60 - <std[c5ab73980a16b942]::thread::lifecycle::spawn_unchecked<rustc_interface[9d19a1b9741214bc]::util::run_in_thread_with_globals<rustc_interface[9d19a1b9741214bc]::util::run_in_thread_pool_with_globals<rustc_interface[9d19a1b9741214bc]::interface::run_compiler<(), rustc_driver_impl[733b6e0b8e0e976b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a93ae171b9b17a3a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:     0x7f41b173acec - <std[c5ab73980a16b942]::sys::thread::unix::Thread>::new::thread_start
  21:     0x7f41ab26e97a - <unknown>
  22:     0x7f41ab2f22bc - <unknown>
  23:                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.97.0-nightly (bd1e7c794 2026-04-15) 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

For more information about this error, try `rustc --explain E0658`.

@rustbot label +F-macro_guard_matcher

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