Skip to content

Commit 57e11a7

Browse files
karolzwolakytmimi
andauthored
docs: more accurate docs about editon and style_edition options
Co-authored-by: Yacin Tmimi <yacintmimi@gmail.com>
1 parent 21852b6 commit 57e11a7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Configurations.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ Specifies which edition is used by the parser.
539539

540540
The `edition` option determines the Rust language edition used for parsing the code. This is important for syntax compatibility but does not directly control formatting behavior (see [style_edition](#style_edition)).
541541

542-
When running `cargo fmt`, the `edition` is automatically inferred from the `Cargo.toml` file. However, when running `rustfmt` directly, the `edition` must be explicitly set in the configuration file or via the command line.
542+
When running `cargo fmt`, the `edition` is automatically read from the `Cargo.toml` file. However, when running `rustfmt` directly the `edition` defaults to 2015 if not explicitly configured. For consistent parsing between rustfmt and `cargo fmt` you should configure the `edition`.
543543
For example in your `rustfmt.toml` file:
544544

545545
```toml
@@ -2808,10 +2808,10 @@ Controls the edition of the [Rust Style Guide] to use for formatting ([RFC 3338]
28082808

28092809
This option is inferred from the [`edition`](#edition) if not specified.
28102810

2811-
See [Rust Style Editions] for details on style editions.
2812-
Starting with the 2024 edition, Rust introduced changes to default formatting. This can lead to inconsistencies between `rustfmt` and `cargo fmt` if the style edition is not explicitly configured. This is because `cargo fmt` automatically picks up the edition from `Cargo.toml`, while `rustfmt` defaults to the `2015` edition unless otherwise specified.
2811+
See [Rust Style Editions] for details on formatting differences between style editions.
2812+
rustfmt has a default style edition of `2015` while `cargo fmt` infers the style edition from the `edition` set in `Cargo.toml`. This can lead to inconsistencies between `rustfmt` and `cargo fmt` if the style edition is not explicitly configured.
28132813

2814-
To ensure consistent formatting, it is recommended to specify the [`edition`](#edition) or `style_edition` in a `rustfmt.toml` configuration file. For example:
2814+
To ensure consistent formatting, it is recommended to specify the `style_edition` in a `rustfmt.toml` configuration file. For example:
28152815

28162816
```toml
28172817
style_edition = "2024"

0 commit comments

Comments
 (0)