rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Introduce required `language_edition` and `style_edition` inputs for Diff Check

Open jieyouxu opened this issue 1 month ago • 3 comments

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: https://github.com/rust-lang/rustfmt/pull/6681#issuecomment-3438539702

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 avatar Dec 07 '25 08:12 jieyouxu

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.

ytmimi avatar Dec 08 '25 20:12 ytmimi

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

jieyouxu avatar Dec 08 '25 23:12 jieyouxu

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

jieyouxu avatar Dec 09 '25 01:12 jieyouxu

Fixed comment, no other changes.

jieyouxu avatar Dec 20 '25 12:12 jieyouxu