-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.
Description
Rust macros try to be hygienic, soTo make sure you don't break Rust's syntax, it restricts what you can write after an expression, which means you can't do something like this:
macro_rules! do_if_true{
($e:expr $b:block) => {
if $e $b
else {
println!("got false");
}
};
}
Since a block always has curly braces, I would expect an expression could be followed by a block but instead, you get this error:
error: `$e:expr` is followed by `$b:block`, which is not allowed for `expr` fragments
I tested this on both stable (rustc 1.5.0 (3d7cd77 2015-12-04)) and nightly (rustc 1.7.0-nightly (2b8e96d 2015-12-21)), but got the same result.
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.