Skip to content

Replace logos-based RDL formatter with proc_macro2 TokenTree traversal#4064

Draft
Copilot wants to merge 1 commit intomasterfrom
copilot/retry-logos-based-formatter
Draft

Replace logos-based RDL formatter with proc_macro2 TokenTree traversal#4064
Copilot wants to merge 1 commit intomasterfrom
copilot/retry-logos-based-formatter

Conversation

Copy link
Contributor

Copilot AI commented Mar 21, 2026

Reattempts #4009: replaces the hand-written logos-based RDL formatter with one that traverses proc_macro2's native token tree directly. Only two files change.

Changes

  • formatter/mod.rs — Removed ~370 lines (logos enum, manual depth counters, bespoke push_attribute char-scan). Replaced with ~185 lines of TokenTree recursion:

    • { }, ( ), [ ] are already Group nodes in proc_macro2 — no manual depth counters needed; the formatter recurses at the correct indentation level automatically
    • < > generics still use an explicit angle_depth: usize counter (not grouped by the tokenizer)
    • :: and -> detected via Spacing::Joint rather than dedicated lexer tokens
    • ... variadic: joint dots skip the space-trim so , ... formats correctly
    • #[...] attributes parsed recursively in inline mode, eliminating the custom char-scanner
  • Cargo.toml — Removed logos = "0.16". proc_macro2, syn, and quote were already workspace dependencies.

All existing test fixtures produce identical output.

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.

2 participants