Skip to content

Commit

Permalink
docs: revert changing link to rust style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
karolzwolak committed Feb 25, 2025
1 parent d1900e9 commit cc598ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2747,13 +2747,15 @@ See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuri

## `style_edition`

Controls the edition of the [Rust Style Guide](https://doc.rust-lang.org/nightly/style-guide/editions.html?highlight=editions#rust-style-editions) to use for formatting ([RFC 3338])
Controls the edition of the [Rust Style Guide] to use for formatting ([RFC 3338])

- **Default value**: `"2015"`
- **Possible values**: `"2015"`, `"2018"`, `"2021"`, `"2024"` (unstable variant)
- **Stable**: No

This option is inferred from the `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.

To ensure consistent formatting, it is recommended to specify the `edition` or `style_edition` in a `rustfmt.toml` configuration file. For example:
Expand All @@ -2764,6 +2766,7 @@ style_edition = "2024"

Alternatively, you can use the `--style-edition` flag when running `rustfmt` directly.

[Rust Style Editions]: https://doc.rust-lang.org/nightly/style-guide/editions.html?highlight=editions#rust-style-editions
[Rust Style Guide]: https://doc.rust-lang.org/nightly/style-guide/
[RFC 3338]: https://rust-lang.github.io/rfcs/3338-style-evolution.html

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,20 @@ edition = "2024"

### Style Editions

The option `style_edition` controls the edition of the [Rust Style Guide](https://doc.rust-lang.org/nightly/style-guide/editions.html?highlight=editions#rust-style-editions) to use for formatting ([RFC 3338](https://rust-lang.github.io/rfcs/3338-style-evolution.html))
Controls the edition of the [Rust Style Guide] to use for formatting ([RFC 3338])
It is inferred from `edition` if not explicitly set, and defaults to the `2015` edition.

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 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.

To ensure consistent formatting, it is recommended to specify the `edition` or `style_edition` in a `rustfmt.toml` configuration file. For example:

```toml
style_edition = "2024"
```
[Rust Style Editions]: https://doc.rust-lang.org/nightly/style-guide/editions.html?highlight=editions#rust-style-editions
[Rust Style Guide]: https://doc.rust-lang.org/nightly/style-guide/
[RFC 3338]: https://rust-lang.github.io/rfcs/3338-style-evolution.html

## Tips

Expand Down

0 comments on commit cc598ed

Please sign in to comment.