Closed
Description
I tried this code:
#![feature(macro_metavar_expr)]
macro_rules! foo {
( $( $($t:ident),* );* ) => { ${count(t,)} }
}
fn test() {
foo!(a, a; b, b);
}
I expected to see this happen:
Either:
- The macro definition is rejected, leading to a compile error.
${count(t,)}
is interpreted as${count(t)}
, the macro call is expanded to4
.
Instead, this happened:
Compiled successfully, ${count(t,)}
is interpreted as ${count(t, 0)}
, the macro call is expanded to 2
.
This form of ${count()}
metavar expression is not specified in RFC 3086, so this is more of an ask for clarification than a bug report.
Meta
rustc --version --verbose
:
1.71.0-nightly (2023-05-23 5ea3f0ae08c07472239a)
cc #83527
@rustbot label requires-nightly F-macro-metavar-expr