Skip to content

Set rustfmt edition and style_edition for consistency#2525

Merged
evan-oxide merged 1 commit into
masterfrom
evan/rustfmt-edition
May 20, 2026
Merged

Set rustfmt edition and style_edition for consistency#2525
evan-oxide merged 1 commit into
masterfrom
evan/rustfmt-edition

Conversation

@evan-oxide
Copy link
Copy Markdown
Contributor

Before, running rustfmt on an individual file (eg. via an editor plugin) would sometimes produce different formatting than running cargo fmt on the whole workspace. That seems to be because cargo fmt infers the edition and style_edition from Cargo.toml, but rustfmt needs them to be set explicitly in .rustfmt.toml.

Here's a specific formatting difference in case anyone's curious or wants to test it.

rustfmt (before this PR):

use foo::{a::C, B};

cargo fmt (always), and rustfmt (after this PR):

use foo::{B, a::C};

So to be clear, this PR does not change the output of cargo fmt. The only downside I know of is that if we bump the edition of the crates, we'll need to remember to bump it in .rustfmt.toml too.

@evan-oxide evan-oxide marked this pull request as ready for review May 20, 2026 20:30
@evan-oxide evan-oxide merged commit f7d4d8c into master May 20, 2026
188 checks passed
@evan-oxide evan-oxide deleted the evan/rustfmt-edition branch May 20, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants