Skip to content

feat(formatter): place multiline method return types - #3138

Draft
floitsch wants to merge 1 commit into
floitsch/formatter-rewrite.35-method-headersfrom
floitsch/formatter-rewrite.40-return-type-placement
Draft

feat(formatter): place multiline method return types#3138
floitsch wants to merge 1 commit into
floitsch/formatter-rewrite.35-method-headersfrom
floitsch/formatter-rewrite.40-return-type-placement

Conversation

@floitsch

@floitsch floitsch commented Aug 4, 2026

Copy link
Copy Markdown
Member

Part 5 of the formatter rewrite stack. Based on #3139.

This isolates the formatter's one token-order exception in format_return_type.cc.

Generic method lowering still constructs and first selects the ordinary source-order header. Only when the selected parameter span is multiline does this pass construct the explicit return-first order:

foo -> ReturnType
    first
    second
:

Flat parameters retain the ordinary form:

foo first second -> ReturnType:

The exception consumes private semantic method pieces through the single select_method_header entry point. No general Layout, SelectedPlan, or repair API gains a relocation operation, and no other formatter component can assemble an alternative method-header order.

The method tests reparse both ordinary and reordered headers, compare their semantic header trees, and format them a second time to verify idempotence. Compiler analysis also passes for both formatter fixtures.

Stack: 5/5.

@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.30-expression-lowering branch from 3ba2486 to be63648 Compare August 4, 2026 23:24
@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.40-return-type-placement branch from fa1440e to 9f37ac8 Compare August 4, 2026 23:24
@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.30-expression-lowering branch from be63648 to 8866616 Compare August 4, 2026 23:27
@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.40-return-type-placement branch from 9f37ac8 to d0524c0 Compare August 4, 2026 23:27
@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.30-expression-lowering branch from 8866616 to a642314 Compare August 5, 2026 01:08
@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.40-return-type-placement branch from d0524c0 to 59ca8f4 Compare August 5, 2026 01:08
@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.40-return-type-placement branch from 59ca8f4 to 7cb7be5 Compare August 5, 2026 01:12
@floitsch
floitsch force-pushed the floitsch/formatter-rewrite.30-expression-lowering branch from a642314 to 1ddf42e Compare August 5, 2026 01:12
@floitsch
floitsch changed the base branch from floitsch/formatter-rewrite.30-expression-lowering to floitsch/formatter-rewrite.35-method-headers August 5, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant