Replace logos-based RDL formatter with proc_macro2 TokenTree traversal#4064
Draft
Replace logos-based RDL formatter with proc_macro2 TokenTree traversal#4064
Conversation
Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/windows-rs/sessions/53aa84be-7b14-425c-855b-e7c72210330e
Copilot created this pull request from a session on behalf of
kennykerr
March 21, 2026 23:31
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reattempts #4009: replaces the hand-written
logos-based RDL formatter with one that traversesproc_macro2's native token tree directly. Only two files change.Changes
formatter/mod.rs— Removed ~370 lines (logos enum, manual depth counters, bespokepush_attributechar-scan). Replaced with ~185 lines ofTokenTreerecursion:{ },( ),[ ]are alreadyGroupnodes in proc_macro2 — no manual depth counters needed; the formatter recurses at the correct indentation level automatically< >generics still use an explicitangle_depth: usizecounter (not grouped by the tokenizer)::and->detected viaSpacing::Jointrather than dedicated lexer tokens...variadic: joint dots skip the space-trim so, ...formats correctly#[...]attributes parsed recursively in inline mode, eliminating the custom char-scannerCargo.toml— Removedlogos = "0.16".proc_macro2,syn, andquotewere already workspace dependencies.All existing test fixtures produce identical output.