-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
WIP: Gate generating mod
items in procedural macros
#50587
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
@bors: try |
@rust-lang/infra, could this be queued up for a check-only crater run? |
⌛ Trying commit bf3a1f146ad648bca69083a52dea192ba7a65e1f with merge d8c55432067be68f5e33e1472daddd580de55bca... |
@bors: try |
⌛ Trying commit 37b3c5e with merge d5fe9545473461c4b00b487ae07543b8d8646f3c... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☀️ Test successful - status-travis |
Crater run started. |
@alexcrichton |
Crater run finished: https://cargobomb-reports.s3.amazonaws.com/pr-50587/index.html. |
Alrighty-roo, thanks @Mark-Simulacrum! Definitely seems like we can't land this as-is, I'll file a follow-up. |
This commit feature gates generating modules and macro definitions in procedural macro expansions. Custom derive is exempt from this check as it would be a large retroactive breaking change (rust-lang#50587). It's hoped that we can hopefully stem the bleeding to figure out a better solution here before opening up the floodgates. The restriction here is specifically targeted at surprising hygiene results [1] that result in non-"copy/paste" behavior. Hygiene and procedural macros is intended to be avoided as much as possible for Macros 1.2 by saying everything is "as if you copy/pasted the code", but modules and macros are sort of weird exceptions to this rule that aren't fully fleshed out. [1]: rust-lang#50504 (comment) cc rust-lang#50504
rustc: Disallow modules and macros in expansions This commit feature gates generating modules and macro definitions in procedural macro expansions. Custom derive is exempt from this check as it would be a large retroactive breaking change (#50587). It's hoped that we can hopefully stem the bleeding to figure out a better solution here before opening up the floodgates. The restriction here is specifically targeted at surprising hygiene results [1] that result in non-"copy/paste" behavior. Hygiene and procedural macros is intended to be avoided as much as possible for Macros 1.2 by saying everything is "as if you copy/pasted the code", but modules and macros are sort of weird exceptions to this rule that aren't fully fleshed out. [1]: #50504 (comment) cc #50504
Discovered in #50504 the hygiene here is super questionable, so we'll likely want to gate this by default for procedural macros and procedural attributes for sure. This is a PR to evaluate the impact for procedural derive as well.