Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for procedural macros and "hygiene 2.0" #54727
Comments
alexcrichton
added
A-macros
T-lang
B-unstable
A-macros-2.0
C-tracking-issue
labels
Oct 1, 2018
added a commit
to alexcrichton/rust
that referenced
this issue
Oct 1, 2018
petrochenkov
self-assigned this
Oct 1, 2018
This comment has been minimized.
This comment has been minimized.
|
To give some background, So, it's pretty heterogeneous and is not even entirely about hygiene. |
This comment has been minimized.
This comment has been minimized.
|
Copypasting what I wrote in #52121: None of these features is blocked on hygiene, except for
What is really blocked on hygiene is |
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
referenced this issue
Oct 1, 2018
Closed
Tracking issue for RFC 1566: Procedural macros #38356
added a commit
to alexcrichton/rust
that referenced
this issue
Oct 1, 2018
This comment has been minimized.
This comment has been minimized.
CodeSandwich
commented
Oct 1, 2018
|
This looks like the right branch for this question. Sorry about copy-paste, but I really need to know. It seems that since I understand, that this is necessary in order to preserver spans, hygiene and consistency with processed code. Is there or will be any way to work with content of modules in separate files? Its lack may be confusing for end users when trivial refactoring of module organization causes change in macro behavior. |
This comment has been minimized.
This comment has been minimized.
|
@CodeSandwich cc @tinco |
This comment has been minimized.
This comment has been minimized.
From what I remember, this is an open question. The "early expansion behavior" looks preferable to me, and this change in behavior looks like a bug rather than a fix. |
This comment has been minimized.
This comment has been minimized.
|
I lack some context, so I can't be certain, what exactly is "process"? If it relies on rustc's pretty printing, then yes this would be a consequence of #52319, and it should be simple to fix by changing the invocation I think. #52319 does two things:
If you need the expanded file, then that should be made explicit in the invocation of the pretty printer. |
This comment has been minimized.
This comment has been minimized.
|
Yes, the change is likely due to the pretty-printing change. |
This comment has been minimized.
This comment has been minimized.
|
If you can point me at the line of code that invokes the pretty printer, I can suggest a fix. |
This comment has been minimized.
This comment has been minimized.
CodeSandwich
commented
Oct 2, 2018
•
|
By "processing" I mean parsing TokenStream with Syn to an Item, modifying its content and converting it back to TokenStream. The precise spot of parsing is here and content traversal is there. I haven't dug into implementation of Syn yet, so I can't tell for sure if it uses pretty printing. I've set |
This comment has been minimized.
This comment has been minimized.
|
I personally feel that what a proc macro receives as input tokens when attached to a module is an open questions, as @petrochenkov said. I do not think that one answer is clearly correct over another ( |
This comment has been minimized.
This comment has been minimized.
|
I'm confused why proc macros expanding to |
This comment has been minimized.
This comment has been minimized.
|
@eddyb I hoped to at least get rid of the "context transplantation trick" before stabilizing it, but got distracted by the edition stuff. It generally works though, I'm not aware of any specific bugs manifesting in normal cases. |
This comment has been minimized.
This comment has been minimized.
|
|
HMPerson1
referenced this issue
Oct 20, 2018
Closed
Spans lost with `feature(proc_macro_hygiene)` #55232
steveklabnik
referenced this issue
Oct 25, 2018
Closed
Function-like procedural macros in expression position as seen in 1.30 announcement are not stable yet #285
dhardy
referenced this issue
Nov 2, 2018
Closed
Parsing an Expr fails with embedded macros in expression position #526
This comment has been minimized.
This comment has been minimized.
dbeckwith
commented
Jan 3, 2019
|
|
This comment has been minimized.
This comment has been minimized.
|
@dbeckwith @alexcrichton -- do you remember a reason for gating expansion to types, other than "types are not items"? |
This comment has been minimized.
This comment has been minimized.
|
I'm not aware of any issues preventing stabilization of fn-like macros expanding into types. |
This comment has been minimized.
This comment has been minimized.
|
@jebrosen IIRC it's just "types weren't items" at the time, so if others agree seems like we could stabilize it! |
alexcrichton commentedOct 1, 2018
This is intended to be a tracking issue for enabling procedural macros to have "more hygiene" than the copy/paste hygiene they have today. This is a very vague tracking issue and there's a very long and storied history to this. The intention here though is to create a fresh tracking issue to collect the current state of play, in hopes that we can close some of the much older and very long issues which contain lots of outdated information.