-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multi-statement macros #10681
Comments
Macros expanding to statements seem kind of broken right now even without this: #[feature(macro_rules)]
macro_rules! foo (
() => (
struct Foo;
)
)
fn main() {
foo!()
}
|
I haven't been working on it. |
Still an issue
Would this require an RFC? |
@treeman no, I don't believe so. |
@sfackler I feel like this issue is still open, but the original example you have compiles today. Do you have an updated example for this? |
macro_rules! foo (
() => (
struct Foo;
struct Bar;
)
);
fn main() {
foo!();
} |
The situation is improved by #24155 but there are still hygiene issues (reported). Here is an example: http://is.gd/sGjll7 |
Another example: http://is.gd/oZTig7 |
triage: multi statement macros are still allowed, but broken, because hygiene runs separately on each statement, so any bindings introduced are not accessible, even within the macro expansion. |
This was fixed in #32923. |
Yay! |
make [`len_zero`] lint not spanning over parenthesis sorry it should be a quick fix but I was caught up by other stuffs last couple weeks 🤦♂️ --- fixes: rust-lang#10529 changelog: make [`len_zero`] lint not spanning over parenthesis
Macros can now expand to multiple items, but not multiple statements. This is a bit sad, especially since a macro that can expand in a module can't expand in a function. This will probably require a bit of restructuring in the parser, since there doesn't seem to be a good way to parse a series of expressions.
parser::parse_block_tail
is almost right, but would need to be pulled apart a bit.The text was updated successfully, but these errors were encountered: