-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Method macros #15646
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
Method macros #15646
Conversation
This change propagates to many locations, but because of the Macro Exterminator (or, more properly, the invariant that it protects), macro invocations can't occur downstream of expansion. This means that in librustc and librustdoc, extracting the desired field can simply assume that it can't be a macro invocation. Functions in ast_util abstract over this check.
This is nice for macros, to allow them to expand into multiple methods
nothing wrong with a statement expanding into 0 stmts, that I can see.
this allows macro results to be parsed as methods
Tidy issues: https://travis-ci.org/rust-lang/rust/jobs/29834978 |
@sfackler fixed, thanks! |
r=me with the test and fix for the test squashed |
cmr: which test squashed? one commit is a run-pass test, the other is a unit test. Or am I misunderstanding you? |
You're right, my bad. |
This patch adds support for macros in method position. It follows roughly the template for Item macros, where an outer `Method` wrapper contains a `Method_` enum which can either be a macro invocation or a standard macro definition. One note; adding support for macros that expand into multiple methods is not included here, but should be a simple parser change, since this patch updates the type of fold_macro to return a smallvector of methods. For reviewers, please pay special attention to the parser changes; these are the ones I'm most concerned about. Because of the small change to the interface of fold_method, this is a ... [breaking change]
On Jul 14, 2014, at 7:06 AM, Mitchell Nordine [email protected] wrote:
Can you provide an example? Many thanks, John Clements |
This patch adds support for macros in method position. It follows roughly the template for Item macros, where an outer
Method
wrapper contains aMethod_
enum which can either be a macro invocation or a standard macro definition.One note; adding support for macros that expand into multiple methods is not included here, but should be a simple parser change, since this patch updates the type of fold_macro to return a smallvector of methods.
For reviewers, please pay special attention to the parser changes; these are the ones I'm most concerned about.
Because of the small change to the interface of fold_method, this is a ...
[breaking change]