Open
Description
It was expected that I could repeat the syntax of the closure in the macro, I repeated but the rule is not working out correctly.
Code:
macro_rules! test {
[ | $($args:ident),* | $($block:tt)* ] => {
| $($args),* | $($block)*
};
}
fn main() {
let enc = &test! {
|a| {
println!("1");
}
} as &'static dyn FnMut(usize);
let enc2 = &test! {
|| {
println!("2");
}
} as &'static dyn FnMut();
}
Output:
error: no rules expected the token `||`
--> src/main.rs:16:9
|
2 | macro_rules! test {
| ----------------- when calling this macro
...
16 | || {
| ^^ no rules expected this token in macro call
Macro code using one or more elements works, but macro code without elements does not work. Although this is precisely the rule with the star.
Rust Version: stable 1.43.1 or rustc 1.45.0-nightly (a74d186 2020-05-14)
Metadata
Metadata
Assignees
Labels
Area: The grammar of RustArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: The lexing & parsing of Rust source code to an ASTCategory: A feature request, i.e: not implemented / a PR.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team