Skip to content
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

Use edition of macro_rules when compiling the macro #133274

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Nov 21, 2024

This changes the edition assigned to a macro_rules macro when it is compiled to use the edition of where the macro came from instead of the local crate's edition.

This fixes a problem when a macro_rules macro is created by a proc-macro. Previously that macro would be tagged with the local edition, which would cause problems with using the correct edition behavior inside the macro. For example, the check for unsafe attributes would cause errors in 2024 when using proc-macros from older editions.

This is partially related to #132906. Unfortunately this is only a half fix for that issue. It fixes the error that happens in 2024, but does not fix the lint firing in 2021. I'm still trying to think of some way to fix that, but I'm running low on ideas.

@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2024

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 21, 2024
@rust-log-analyzer

This comment has been minimized.

@ehuss ehuss force-pushed the macro_rules-edition-from-pm branch from 94c2a92 to 993e084 Compare November 21, 2024 01:29
@compiler-errors
Copy link
Member

Do you expect this to have any effect on preexisting code? In that case, should we crater this change?

@petrochenkov
Copy link
Contributor

It would be better to run crater on this.

@compiler-errors
Copy link
Member

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 21, 2024
…=<try>

Use edition of `macro_rules` when compiling the macro

This changes the edition assigned to a macro_rules macro when it is compiled to use the edition of where the macro came from instead of the local crate's edition.

This fixes a problem when a macro_rules macro is created by a proc-macro. Previously that macro would be tagged with the local edition, which would cause problems with using the correct edition behavior inside the macro. For example, the check for unsafe attributes would cause errors in 2024 when using proc-macros from older editions.

This is partially related to rust-lang#132906. Unfortunately this is only a half fix for that issue. It fixes the error that happens in 2024, but does not fix the lint firing in 2021. I'm still trying to think of some way to fix that, but I'm running low on ideas.
@bors
Copy link
Contributor

bors commented Nov 21, 2024

⌛ Trying commit 993e084 with merge 9a6ce9b...

@bors
Copy link
Contributor

bors commented Nov 21, 2024

☀️ Try build successful - checks-actions
Build commit: 9a6ce9b (9a6ce9bcee4fff9f2010ea88aaa7654cc4d95132)

@compiler-errors
Copy link
Member

@craterbot check p=10

@craterbot
Copy link
Collaborator

👌 Experiment pr-133274 created and queued.
🤖 Automatically detected try build 9a6ce9b
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 21, 2024
@compiler-errors
Copy link
Member

@rust-timer build 9a6ce9b

@rust-timer
Copy link
Collaborator

Queued 9a6ce9b with parent 717f5df, future comparison URL.
There is currently 1 preceding artifact in the queue.
It will probably take at least ~2.1 hours until the benchmark run finishes.

@craterbot
Copy link
Collaborator

🚧 Experiment pr-133274 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@compiler-errors
Copy link
Member

Actually why did I start rust-timer on this? Anyways, ignore that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-crater Status: Waiting on a crater run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants