From 57e11a74b0538a49387da76752c353391d3ee495 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Thu, 27 Feb 2025 10:49:32 +0100 Subject: [PATCH] docs: more accurate docs about `editon` and `style_edition` options Co-authored-by: Yacin Tmimi --- Configurations.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Configurations.md b/Configurations.md index 46fc4c1772f..6d2d687654e 100644 --- a/Configurations.md +++ b/Configurations.md @@ -539,7 +539,7 @@ Specifies which edition is used by the parser. 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)). -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. +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`. For example in your `rustfmt.toml` file: ```toml @@ -2808,10 +2808,10 @@ Controls the edition of the [Rust Style Guide] to use for formatting ([RFC 3338] This option is inferred from the [`edition`](#edition) if not specified. -See [Rust Style Editions] for details on style editions. -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. +See [Rust Style Editions] for details on formatting differences between style editions. +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. -To ensure consistent formatting, it is recommended to specify the [`edition`](#edition) or `style_edition` in a `rustfmt.toml` configuration file. For example: +To ensure consistent formatting, it is recommended to specify the `style_edition` in a `rustfmt.toml` configuration file. For example: ```toml style_edition = "2024"