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

[macro_metavars_in_unsafe]: recognize metavariables in tail expressions #13220

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

y21
Copy link
Member

@y21 y21 commented Aug 5, 2024

Fixes #13219

macro_metavars_in_unsafe keeps track of the current "expansion depth" (incremented/decremented when entering/leaving a macro span) to tell if an expression from the root context is contained within a macro (see the doc comment I added for a hopefully better explanation)

Before this PR, we didn't increment said expn_depth for unsafe blocks within macros, because we already do that in visit_stmt anyway, so it would work fine for statements, but that's not enough for tail expressions of an unsafe block.

So we now also increment it for macro unsafe blocks.
Also updated the comment for expn_depth while I'm at it because "This is not necessary for correctness" isn't correct now that I think about it


changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Aug 5, 2024

r? @dswij

rustbot has assigned @dswij.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 5, 2024
@ojeda
Copy link
Contributor

ojeda commented Aug 5, 2024

That was quick, thanks!

Copy link
Member

@dswij dswij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dswij
Copy link
Member

dswij commented Aug 10, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Aug 10, 2024

📌 Commit 234a1d3 has been approved by dswij

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 10, 2024

⌛ Testing commit 234a1d3 with merge 37f98ff...

@bors
Copy link
Contributor

bors commented Aug 10, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: dswij
Pushing 37f98ff to master...

@bors bors merged commit 37f98ff into rust-lang:master Aug 10, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macro_metavars_in_unsafe does not lint "without a statement".
5 participants