Skip to content

Conversation

@jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Dec 7, 2025

So that when manually dispatching the Diff Check workflow, an explicit pair of {language edition, style edition} are specified.

  • E.g. if language edition is not specified, rustfmt will default to Edition 2015 like rustc, which can cause a lot of parse errors in the current set of candidate projects used for comparing rustfmt behaviors since they tend to be on Edition 2024.
  • Similarly, when style edition is not specified, rustfmt can pick a lower default style edition than the actual language edition, which can also lead to unexpected diff check outcomes.

Note that the language/style editions specified with language_edition/style_edition inputs can still be overridden by rustfmt_configs, but the intention is to make sure the language_edition/style_edition are always specified.

Context: #6681 (comment)

Separate --edition/--style-edition vs --config=edition=...,style_edition=...

See discussion in #t-rustfmt > style edition flag vs config.

In this PR I use the --config=style_edition=$STYLE_EDITION form, because I'm not actually sure what's the precedence order of mixed invocations (example below), so I just used --config=style_edition=$STYLE_EDITION where later style_editions specified in optional rustfmt_configs should take precedence over this input.

$ rustfmt --style-edition=2024 --config=style_edition=2021
$ rustfmt --config=style_edition=2021 --style-edition=2024

Review remarks

The first commit in this PR is a drive-by fix for rusfmt -> rustfmt that was bothering me, should not contain any functional changes.

The following commits are the actual script/workflow changes.

@jieyouxu jieyouxu added the A-CI Area: CI label Dec 7, 2025
@ytmimi
Copy link
Contributor

ytmimi commented Dec 8, 2025

Just want to note that rustfmt defaults to using edition=2015 if it's not explicitly specified in the rustfmt.toml so it might also be useful to add an --edition argument as well so we can more easily control how code is parsed because certain syntax doesn't parse using the default edition.

@jieyouxu
Copy link
Member Author

jieyouxu commented Dec 8, 2025

Hm, good point. I'll also make that explicit.

@jieyouxu jieyouxu force-pushed the diff-check-style-edition branch from f04c92f to b2b5306 Compare December 9, 2025 01:20
@jieyouxu jieyouxu changed the title Introduce a required style_edition input for Diff Check Introduce required language_edition and style_edition inputs for Diff Check Dec 9, 2025
@jieyouxu
Copy link
Member Author

jieyouxu commented Dec 9, 2025

Updated the PR to also make language edition explicit. Also rebased since #6741 merged.

No functional changes. Just was bothering me :D
So that when manually dispatching the Diff Check workflow, an explicit
style edition is specified.

Note that the style edition specified with `style_edition` input can
still be overridden by `rustfmt_configs`, but the intention is to make
sure the `style_edition` is always specified.
When a language edition is not specified, `rustfmt` will default to
Edition 2015 (like `rustc`), which tends to cause parse errors in the
preset set of candidate projects being used for comparison.

Introduce a required `language_edition` input for the Diff Check
workflow (and the `check_diff.sh` script) so that the contributor
invoking the workflow is much less likely to miss specifying the
language edition. Like the previous `style_edition` input, the language
edition can also be overriden by `edition=...` settings in the later
optional `rustfmt_configs` input for consistency.
@jieyouxu jieyouxu force-pushed the diff-check-style-edition branch from b2b5306 to de4e3e7 Compare December 9, 2025 01:26
@jieyouxu jieyouxu marked this pull request as ready for review December 9, 2025 01:27
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.

3 participants