A good question! I don’t think hygiene has been super concretely defined in terms of what it means for Rust, but what this “Macros 1.2” proposal is saying is that we’ll do exactly what macro_rules! does today. When you define an item with a macro it enters the same namespace as the surrounding scope, name collisions and all.
To be clear, this is exactly the case already today with derive(Foo) and macro_rules!. This has long been considered a bug in rustc that we’d like to fix, and that’s what the hypothetical “hygiene in macros 2.0” will solve, where you can select what scope the names are defined in.
This proposal, however, is basically saying “let’s hold off on these hypothetical and not concretely defined plans and extend the current system in a familiar way that macros operate in today”.
Dealing with editions doesn’t come into hygiene, these macros will basically allow inserting names into a module which other items can also reach, just like macro_rules! does today. Many questions can basically be answered “what does macro_rules! do today?”
Yes, do you find that RFC 1560/1561 are lacking details, though? The tracking issue also has details on how #[macro_export] is still needed but #[macro_use] will no longer be needed. There is also information about how it is a known and accepted aspect that macro_rules! macros don’t live in modules when you import them (a limitation of the stable macro_rules! system).
Good questions! You’re correct in that macro 1.2 does not make progress in hygiene, it is sticking with exactly what we have today with macro_rules!. In that sense the hygiene afficianados we have agree that the proposal here is adequately forward-compatible with future possible hygiene systems. (this is what we discussed quite a bit in Berlin)
Correct.
Is the OP unclear in this respect? From what I outlined there the pieces are:
- Importing macros through the module system
- Attribute macros, only attached to items but not modules.
- Custom bang-style macros, but only invoked in module contexts, not as expressions or inside functions.
- No hygiene information through explicitly requesting “call site” hygiene, aka copy/pasting code.
- A large chunk of the proc_macro API to enable preserving span information on tokens.
I can’t necessarily predict the future so I have no idea if 1.3 will happen, but I don’t see hwo that would impact the 1.2 issue?
The set of features unstabilized and yet-to-be-explored is quite amorphous and always changing, but is that necessarily required for staiblizing 1.2?
@mark-i-m you’ve definitely got a lot of great questions, but I feel like the meaty pieces (module system and such) are already RFC’d? The proposal here is explicitly a slice of what we have already RFC’d and implemented today, which is why I’d like to move to FCP later in this cycle. Nothing new is being introduced here other than the idea of what subset should be stabilized I believe.