Skip to content

Preserve whole group spans across compiler token conversions - #32

Closed
faysou wants to merge 2 commits into
aacebo:masterfrom
faysou:fix-compiler-group-spans
Closed

faysou wants to merge 2 commits into
aacebo:masterfrom
faysou:fix-compiler-group-spans

Conversation

@faysou

@faysou faysou commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Keep the compiler's whole-group span alongside the opening and closing delimiter spans when converting proc_macro and proc_macro2 groups. The array round-trip regression checks that a diagnostic can highlight the whole group.

The proc-macro span and trybuild tests pass.

Related to #25.

Converting a `proc_macro::Group` kept only its delimiter spans, and
converting back joined them. On stable `Span::join` returns the second
span, so a group that went through moxy covered only its closing
delimiter. Diagnostics on a re-emitted group pointed at that delimiter
(an array literal of the wrong length underlined `]`), and a lint that
reads the source between a keyword and a group, such as clippy's
`suspicious_else_formatting` on `} else {`, read the whole block and
fired on correctly formatted code.

`DelimSpan` now stores the whole group's span next to the delimiter
spans. The `proc_macro` and `proc_macro2` bridges fill it from the
compiler's group span, and `DelimSpan::new` still joins the two
delimiter spans. Three derive error fixtures now underline the whole
node they name instead of its last token, and a trybuild fixture covers
the round trip.
@faysou
faysou force-pushed the fix-compiler-group-spans branch from 3a4807f to 3d9d112 Compare November 21, 2026 07:07
@faysou faysou closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant