Skip to content

Conversation

@ytmimi
Copy link
Contributor

@ytmimi ytmimi commented Dec 21, 2025

The Diff Check Job is integral to making sure we don't introduce breaking formatting changes. An effort was started by a contributor a while ago to rewrite the tool in rust, but that stalled out. I'd like to cut over to this rewritten rust version, which I think is an improvement over the current shell script and I think it should should help us get things unstuck and allow us to complete the next subtree sync with confidence that we're not introducing any breaking changes.

The PR is broken up into smaller commits, and I'd recommend reviewing things one commit at a time, but also happy to break this up into smaller commits if that's preferred.

Note: I plan to update the .github/workflows/check_diff.yml in a follow PR after this lands

r? @calebcartwright @jieyouxu @Manishearth

@ytmimi ytmimi marked this pull request as draft December 21, 2025 16:43
@ytmimi ytmimi force-pushed the update_rust_check_diff branch from db0480a to 01e646c Compare December 21, 2025 16:49
@ytmimi ytmimi force-pushed the update_rust_check_diff branch 4 times, most recently from c3cd596 to 8bf953a Compare December 23, 2025 17:30
@ytmimi ytmimi force-pushed the update_rust_check_diff branch from 8bf953a to 78fdb19 Compare January 8, 2026 00:48
ytmimi added 12 commits January 10, 2026 13:16
This is how cargo determines which environment variable to set when
running `cargo run` and helps to allow the binary to run on more
operating systems than just linux.
I think this makes the overall code better. Also removes an unecessary
lifetime annotation.
in most cases I'd expect to get valid UTF-8, and in the rare event that
we don't get valid UTF-8 including some replacement characters should be
fine.
The `CheckDiffError` that was returned in the error case was too broad
and I felt that the code could be simplified if we returned a type that
specifically captured what went wrong.
The `CheckDiffError` that was previously returned in the error case was
too broad and I felt that the code could be simplified if we returned a
type that specifically captured what went wrong when trying to create a
diff between two formatter.
This updates some logging output to be more descriptive and also adds
some `debug!` and `error!` logging.
Now after we compile both rustfmt binaries we iterate through each
repository and process each check in its own thread.

This implementation more or less follows the behavior from
`ci/check_diff.sh`, but it's faster since we're able to process each
repository in parallel.
When rustfmt knows the file path it's able to skip formatting for files
listed in the repo's rustfmt.toml `ignore` list. This helps when us
process files in r-l/rust that have been explicitly skipped. Otherwise
we'll try to format files that cause rustfmt to hang.
`i32` didn't seem like the right return type to me. Since we're just
recording that any error happened `u8` seemed good enough for that.
This let's us controll the rust language edition used to parse source
code and the rustfmt style edition used for code formatting.
@ytmimi ytmimi force-pushed the update_rust_check_diff branch from 78fdb19 to 45967f5 Compare January 11, 2026 19:51
@ytmimi ytmimi marked this pull request as ready for review January 11, 2026 19:52
@ytmimi ytmimi changed the title WIP: Get the Check Diff rust binary working Get the Check Diff rust binary working Jan 13, 2026
@jieyouxu jieyouxu self-assigned this Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants