Skip to content

check_fmt --fix: never drop code when rustfmt moves lines - #104

Merged
wogglesl-review[bot] merged 1 commit into
mainfrom
fix-check-fmt
Dec 3, 2026
Merged

wogglesl-review[bot] merged 1 commit into
mainfrom
fix-check-fmt

Conversation

@R3disme

@R3disme R3disme commented Dec 3, 2026

Copy link
Copy Markdown
Member

tools/check_fmt.py --fix deleted four pub mod lines from src/widget.rs in #100 (field, key_chip, segmented, switch), so those widgets stopped being compiled. #103 adds them back.

Cause: rustfmt sorts mod/use items. A move shows up as two hunks, a removal and an insertion further down. --fix only applied hunks touching lines the branch changed, so it applied the removal and skipped the insertion.

Fix:

  • Hunks that carry the other half of a move (the same lines removed in one and added in another) are applied together.
  • Before writing, it compares each file's code before and after, ignoring whitespace, commas and braces. If anything would be lost or duplicated, it refuses and asks for a full cargo fmt on that file.

Tested: I re-created the #100 situation (the four lines inserted after pub mod badge;). The check reported it, --fix moved the lines into sorted order instead of deleting them, and the check then passed.

Wiki: not needed - developer tool only.

@R3disme
R3disme requested review from a team as code owners December 3, 2026 13:47
@R3disme R3disme added In-Review Finished and waiting for a maintainer's review wiki-not-needed Change does not need a wiki update labels Dec 3, 2026
Copilot AI balanced review requested due to automatic review settings December 3, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@R3disme

R3disme commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

@WoggleSL/review approve

@wogglesl-review wogglesl-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved by @R3disme.

Checks

  • ✅ Build linux-x86_64
  • ✅ Build windows-x86_64
  • ❌ dispatch (not required)
  • ❌ wiki (not required)
  • ✅ retake screenshots (not required)
  • ✅ changes (not required)
  • ✅ codeql (actions) (not required)
  • ✅ sync (not required)
  • ✅ dispatch (not required)
  • ✅ wiki (not required)
  • ✅ changes (not required)
  • ⏳ codeql (rust) (not required)
  • ⏳ preview screenshots (not required)
  • ✅ screenshots out of date (not required)
  • ✅ screenshots out of date (not required)
  • ✅ Build macos-universal (not required)
  • ✅ secrets (not required)
  • ❌ typos (not required)
  • ✅ Build flatpak-x86_64 (not required)
  • ✅ fmt (not required)
  • ⏳ clippy (not required)
  • ✅ Release (not required)
  • ⏳ test (not required)
  • ✅ cargo-deny (not required)
  • ✅ unsafe (not required)
  • ✅ dependency-review (not required)
  • ✅ workflows (not required)
  • ✅ translations (not required)
  • ✅ flag-lists (not required)
  • ✅ CodeQL (not required)

Change: 1 files, +57 / -7, 1 commit(s) by @R3disme
Merges into: main without conflicts

WoggleSL Review · requested by @R3disme from a comment

@wogglesl-review
wogglesl-review Bot merged commit 435a868 into main Dec 3, 2026
25 of 30 checks passed
@wogglesl-review

Copy link
Copy Markdown

Squash-merged into main as 435a868.

WoggleSL Review · requested by @R3disme from a comment

@wogglesl-review
wogglesl-review Bot deleted the fix-check-fmt branch December 3, 2026 13:51
@wogglesl-review wogglesl-review Bot removed the In-Review Finished and waiting for a maintainer's review label Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wiki-not-needed Change does not need a wiki update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants