Open
Description
auto-reduced (treereduce-rust):
macro_rules! a {
( $( { $( [ $( ( $( $foo:ident )* ) )* ] )* } )* ) => {
(
$,
$(u128::{
const ${concat(FOO, $foo)}: i32 = 2;
}, ),
//~^ ERROR depth parameter of meta-variable expression `count` must be less than 4
)
};
}
macro_rules! b {
( $( { $( [ $( $foo:ident )* ] )* } )* ) => ;
}
fn main() {
a!( { [ (a) ] [ (b c) ] } );
c!({ a });
}
original code
original:
#![feature(macro_metavar_expr)]
macro_rules! a {
( $( { $( [ $( ( $( $foo:ident )* ) )* ] )* } )* ) => {
(
${count($foo, 0)},
$(u128::from_le_bytes{
const ${concat(FOO, $foo)}: i32 = 2;
//~^ ERROR variable `foo` is not recognized in meta-variable expression
}, 0x40029000000000000000000000000000),
//~^ ERROR depth parameter of meta-variable expression `count` must be less than 4
)
};
}
macro_rules! b {
( $( { $( [ $( $foo:ident )* ] )* } )* ) => {
(
$( $( $(
${ignore($foo)}
${index($p:path |)},
${index(10)},
//~^ ERROR depth parameter of meta-variable expression `index` must be less than 3
)* )* )*
)
};
}
macro_rules! c {
( $( { $( $foo:ident )* } )* ) => {
(
$( $(
${ignore($foo)}
${len(0)}
${len(10)}
//~^ ERROR depth parameter of meta-variable expression `len` must be less than 2
)* )*
)
};
}
fn main() {
a!( { [ (a) ] [ (b c) ] } );
b!( { [ a b ] } );
c!({ a });
}
Version information
rustc 1.88.0-nightly (efcbb94dc 2025-04-29)
binary: rustc
commit-hash: efcbb94dccbe0fcc1076f031f88332db4a6a2a52
commit-date: 2025-04-29
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Possibly related line of code:
rust/compiler/rustc_expand/src/mbe/transcribe.rs
Lines 789 to 801 in efcbb94
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error: expected identifier, found `,`
--> /tmp/icemaker_global_tempdir.3KWQbQU9CIWz/rustc_testrunner_tmpdir_reporting.JmL2GUsKp85j/mvce.rs:4:14
|
4 | $,
| ^
error[E0658]: the `concat` meta-variable expression is unstable
--> /tmp/icemaker_global_tempdir.3KWQbQU9CIWz/rustc_testrunner_tmpdir_reporting.JmL2GUsKp85j/mvce.rs:6:16
|
6 | const ${concat(FOO, $foo)}: i32 = 2;
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #124225 <https://github.com/rust-lang/rust/issues/124225> for more information
= help: add `#![feature(macro_metavar_expr_concat)]` to the crate attributes to enable
= note: this compiler was built on 2025-04-29; consider upgrading it if it is out of date
error: expected one of: `*`, `+`, or `?`
--> /tmp/icemaker_global_tempdir.3KWQbQU9CIWz/rustc_testrunner_tmpdir_reporting.JmL2GUsKp85j/mvce.rs:8:9
|
8 | }, ),
| ^
error: macro rhs must be delimited
--> /tmp/icemaker_global_tempdir.3KWQbQU9CIWz/rustc_testrunner_tmpdir_reporting.JmL2GUsKp85j/mvce.rs:15:49
|
15 | ( $( { $( [ $( $foo:ident )* ] )* } )* ) => ;
| ^
thread 'rustc' panicked at compiler/rustc_expand/src/mbe/transcribe.rs:795:54:
not implemented
stack backtrace:
0: 0x7b592550bf73 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h70d0b0bf7dabcc62
1: 0x7b5925c059c7 - core::fmt::write::h95cfb50f7a1a4aed
2: 0x7b5927055811 - std::io::Write::write_fmt::he4f9617dc005cd64
3: 0x7b592550bdd2 - std::sys::backtrace::BacktraceLock::print::h6e0bf7d3d1f1df33
4: 0x7b592550fc1a - std::panicking::default_hook::{{closure}}::h91ad0c7cab45c956
5: 0x7b592550f79f - std::panicking::default_hook::h99b2391f3ee22ec6
6: 0x7b5924589d63 - std[14bf288ed479d8e3]::panicking::update_hook::<alloc[d722d77ad22a6fc8]::boxed::Box<rustc_driver_impl[6cad6eb0dd6473d4]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7b5925510493 - std::panicking::rust_panic_with_hook::h6c88edccaa127d3c
8: 0x7b5925510156 - std::panicking::begin_panic_handler::{{closure}}::h8818f97a6b4edced
9: 0x7b592550c439 - std::sys::backtrace::__rust_end_short_backtrace::h029db3b8bf007b60
10: 0x7b592550fe4d - __rustc[7b288356a4aef171]::rust_begin_unwind
11: 0x7b5921e8e590 - core::panicking::panic_fmt::hd1ef7fd41505b481
12: 0x7b5921e931dc - core::panicking::panic::ha19f52c22e6e3c4e
13: 0x7b5926fc9f66 - <rustc_expand[b527a14089d49d16]::expand::MacroExpander>::fully_expand_fragment
14: 0x7b5926f8b1b7 - <rustc_expand[b527a14089d49d16]::expand::MacroExpander>::expand_crate
15: 0x7b592657f87b - rustc_interface[31c3fa0d7a8298a7]::passes::resolver_for_lowering_raw
16: 0x7b592657ec8d - rustc_query_impl[5763ea9fb1f3b9e6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5763ea9fb1f3b9e6]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1fd7e3161c5d5d2a]::query::erase::Erased<[u8; 16usize]>>
17: 0x7b592657ec79 - <rustc_query_impl[5763ea9fb1f3b9e6]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[12175b0b6b0c4721]::ops::function::FnOnce<(rustc_middle[1fd7e3161c5d5d2a]::ty::context::TyCtxt, ())>>::call_once
18: 0x7b5926ab9051 - rustc_query_system[c3322cd89c137a94]::query::plumbing::try_execute_query::<rustc_query_impl[5763ea9fb1f3b9e6]::DynamicConfig<rustc_query_system[c3322cd89c137a94]::query::caches::SingleCache<rustc_middle[1fd7e3161c5d5d2a]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[5763ea9fb1f3b9e6]::plumbing::QueryCtxt, false>
19: 0x7b5926ab8bc0 - rustc_query_impl[5763ea9fb1f3b9e6]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
20: 0x7b5926b2d4f1 - rustc_interface[31c3fa0d7a8298a7]::passes::create_and_enter_global_ctxt::<core[12175b0b6b0c4721]::option::Option<rustc_interface[31c3fa0d7a8298a7]::queries::Linker>, rustc_driver_impl[6cad6eb0dd6473d4]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
21: 0x7b5926cc8eb9 - rustc_interface[31c3fa0d7a8298a7]::interface::run_compiler::<(), rustc_driver_impl[6cad6eb0dd6473d4]::run_compiler::{closure#0}>::{closure#1}
22: 0x7b5926c8b574 - std[14bf288ed479d8e3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[31c3fa0d7a8298a7]::util::run_in_thread_with_globals<rustc_interface[31c3fa0d7a8298a7]::util::run_in_thread_pool_with_globals<rustc_interface[31c3fa0d7a8298a7]::interface::run_compiler<(), rustc_driver_impl[6cad6eb0dd6473d4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
23: 0x7b5926c8b9b4 - <<std[14bf288ed479d8e3]::thread::Builder>::spawn_unchecked_<rustc_interface[31c3fa0d7a8298a7]::util::run_in_thread_with_globals<rustc_interface[31c3fa0d7a8298a7]::util::run_in_thread_pool_with_globals<rustc_interface[31c3fa0d7a8298a7]::interface::run_compiler<(), rustc_driver_impl[6cad6eb0dd6473d4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[12175b0b6b0c4721]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
24: 0x7b5926c8cdab - std::sys::pal::unix::thread::Thread::new::thread_start::hbfc0b8ce62741752
25: 0x7b5920aa370a - <unknown>
26: 0x7b5920b27aac - <unknown>
27: 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.88.0-nightly (efcbb94dc 2025-04-29) 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 4 previous errors
For more information about this error, try `rustc --explain E0658`.
@rustbot label +F-macro_metavar_expr
Metadata
Metadata
Assignees
Labels
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Category: This is a bug.`#![feature(macro_metavar_expr)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: a bisection has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.