-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Consider pass macro invocation arguments as AST instead of TokenTree #12488
Comments
The macro invocation syntax is almost entirely freeform. I'm not sure how much more parsing can be done while still supporting stuff like let map = make_map!(Hey, dude! This map should have type collections::HashMap.
It contains mappings "a" => 1, "b" => 2, "c" => 3); |
cc me. |
I don't know. My hunch is since it is parsed inside macro definition anyway, we should be able to do something at the invocation site as well. |
Macros can also be passed many different AST nodes, like an expression, an item, an ident, a block, a pattern, etc. etc., and there's no way to tell which the macro wants without knowing the definition of the macro (i.e. intertwining parsing and macro expansion, which is a strong negative in my mind). And it's not necessarily "obvious" what a macro wants from the definition, e.g. a procedural macro written in Rust may change what it wants to be fed in non-obvious ways. |
Yes, the point of macros is that you don't parse before the macro has had a crack at it. That's an important property of the MTWT model. I move that we close this issue. |
Yes, I think this can be closed. This would need an RFC today, and I'm not even sure it's what we would want. |
Disable `indexing_slicing` for custom Index impls Fixes rust-lang/rust-clippy#11525 Disables `indexing_slicing` for custom Index impls, specifically any implementations that also do not have a `get` method anywhere along the deref chain (so, for example, it still lints on Vec, which has its `get` method as part of the deref chain). Thanks `@y21` for pointing me in the right direction with a couple of handy util functions for deref chain and inherent methods, saved a headache there! changelog: FP: Disable `indexing_slicing` for custom Index impls
That way, more sophisticated and precise transformation can be performed against AST before being passed into macro definitions. The main use case right now would be hygiene let bindings and loop labels.
Is this doable?
cc #12262 #10607 #12338
The text was updated successfully, but these errors were encountered: