Skip to content

fix: Correctly set the span of the proc_macro crate's Group delimiters #19839

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

Merged
merged 1 commit into from
May 21, 2025

Conversation

ChayimFriedman2
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 commented May 21, 2025

Previously only the open delimiter's span was set, and this caused... weird problems.

Probably fixes (don't close!) #18471, and possibly also #19834. The problem is that we only had the span of the closing parentheses of the call, and for descending attributes we look at the first and last token, but we couldn't find the last token (the closing paren) in the macro. However, there could be other problems too, so I don't want to close them yet before we verify it works (it's hard to test proc macro server changes).

Perhaps it's worth reconsidering our strategy for descending into attribute macros, especially given that when users create their own Groups they have no way of setting each delimiter span separately, only for both.

Previously only the open delimiter's span was set, and this caused... weird problems.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 21, 2025
@ChayimFriedman2 ChayimFriedman2 changed the title Correctly set the span of the proc_macro crate's Group delimiters fix: Correctly set the span of the proc_macro crate's Group delimiters May 21, 2025
@ChayimFriedman2
Copy link
Contributor Author

I try to locate the origin of this code but there was some mess with history due to syncs so I couldn't...

@Veykril
Copy link
Member

Veykril commented May 21, 2025

I try to locate the origin of this code but there was some mess with history due to syncs so I couldn't...

I implemented that logic I believe (or at least parts of it), but there was no concrete reasoning as to why we do the thing the way we do here iirc

Perhaps it's worth reconsidering our strategy for descending into attribute macros, especially given that when users create their own Groups they have no way of setting each delimiter span separately, only for both.

That's a good point, definitely worth revisiting our strategy here.

Also note that some decisions for this were shaped by our token tree model back then. We used to only encode a single TokenId for the delimiter pair (back when we used TokenId), which is nowadays fixed.

@Veykril Veykril added this pull request to the merge queue May 21, 2025
Merged via the queue into rust-lang:master with commit 1511c5b May 21, 2025
14 checks passed
@ChayimFriedman2 ChayimFriedman2 deleted the inlay-hints-attr branch May 21, 2025 19:10
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.

None yet

3 participants