Skip to content

Cargo fmt and rustfmt are using different editions by default #6483

@ranjeethmahankali

Description

@ranjeethmahankali

If I run cargo fmt on my project that targets the 2024 edition, it formats it correctly. If I just run rustfmt on a file, it targets the 2021 edition by default. To be consistent with cargo fmt I have to run rustfmt --edition 2024 <file>.

Is this discrepancy intended?

I noticed this because my editor automatically runs rustfmt on save. So the files keep switching back to 2021 formatting whenever I edit them. I can tweak my editor to not do this, but I figured this might be an unintentional bug that affects others.

Metadata

Metadata

Assignees

Labels

A-2024-style-editionArea: style edition 2024A-configArea: configurationgood first issueIssues up for grabs, also good candidates for new rustfmt contributors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions