[macro_metavars_in_unsafe
]: recognize metavariables in tail expressions
#13220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
forunsafe
blocks within macros, because we already do that invisit_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 itchangelog: none