Skip to content

Conversation

@pgherveou
Copy link
Contributor

@pgherveou pgherveou commented Jan 29, 2026

by default rustfmt preserve local style, and Claude loves to add semi or bracket where there were none before,
We should make the formatting more strict as this is a bit annoying to remind it constantly not to make unnecessary diff.

Summary

The PR is just updating https://github.com/paritytech/polkadot-sdk/blob/pg/stricter-rustfmt-rules/.rustfmt.toml
every other changes are just the result of running the linter

  • Change match_arm_leading_pipes from "Preserve" to "Never" to enforce a single style
  • Change trailing_semicolon from false to true to enforce return 42; false unfortunately preserve the local style
  • Add normalize_comments = true to normalize comment spacing (e.g., // comment not //comment)
  • Add normalize_doc_attributes = true to enforce /// over #[doc = ""]

These changes ensure only one valid formatting style exists, reducing unnecessary diffs in pull requests caused by different but equally valid formatting styles.

Not changed (for now)

The following options also default to "Preserve" but were intentionally not changed due to (even) larger diff impact:

  • group_imports - Would enforce import grouping order (std → external → crate) but causes massive import reordering across the codebase
  • hex_literal_case - Would enforce 0xABCD vs 0xabcd consistency
  • edition 2024 - not sure what that change but it also probably create a big diff

These could be considered in a future PR if the one-time diff cost is acceptable.

@cla-bot-2021
Copy link

cla-bot-2021 bot commented Jan 29, 2026

User @claude, please sign the CLA here.

@pgherveou pgherveou requested review from a team, acatangiu and koute as code owners January 29, 2026 21:25
@paritytech-review-bot paritytech-review-bot bot requested a review from a team January 29, 2026 21:26
@pgherveou pgherveou force-pushed the pg/stricter-rustfmt-rules branch from a71d201 to ca8900c Compare January 29, 2026 21:29
@pgherveou pgherveou force-pushed the pg/stricter-rustfmt-rules branch from 327d5a0 to 3c2df5b Compare January 29, 2026 21:40
@pgherveou pgherveou added the R0-no-crate-publish-required The change does not require any crates to be re-published. label Jan 29, 2026
@pgherveou pgherveou enabled auto-merge January 29, 2026 21:42
@bkchr
Copy link
Member

bkchr commented Jan 29, 2026

/cmd fmt

Copy link
Contributor

@AndreiEres AndreiEres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group_imports - Would enforce import grouping order (std → external → crate) but causes massive import reordering across the codebase

So we should prefer grouping imports already, right?

@bkchr
Copy link
Member

bkchr commented Jan 30, 2026

So we should prefer grouping imports already, right?

I always combine all the imports and not group them.

@pgherveou
Copy link
Contributor Author

the only one I would add maybe is edition -> 2024, since this is a disturbing change we are better off doing it now, wdyt?

@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/21513417618
Failed job name: test-doc

@pgherveou pgherveou added this pull request to the merge queue Jan 30, 2026
Merged via the queue into master with commit c3487a5 Jan 30, 2026
236 of 239 checks passed
@pgherveou pgherveou deleted the pg/stricter-rustfmt-rules branch January 30, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

R0-no-crate-publish-required The change does not require any crates to be re-published.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants