Skip to content

Commit afab171

Browse files
committed
docs: improve tip on edition inconsistency between cargo and rustfmt
1 parent 14f12fb commit afab171

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ style_edition = "2024"
197197

198198
## Tips
199199

200+
* When using `rustfmt` directly in a Cargo project, Cargo will determine [`edition`](rusts-editions) from `Cargo.toml`, but rustfmt will not, as it has its own configuration file, `rustfmt.toml`.
201+
To ensure consistent parsing between `cargo fmt` and `rustfmt`, you should configure the [`edition`](style-editions) in your `rustfmt.toml` file.
202+
To ensure consistent formatting between `cargo fmt` and `rustfmt`, you should configure the [`style_edition`](rusts-editions) in your `rustfmt.toml` file.
203+
200204
* For things you do not want rustfmt to mangle, use `#[rustfmt::skip]`
201205
* To prevent rustfmt from formatting a macro or an attribute,
202206
use `#[rustfmt::skip::macros(target_macro_name)]` or
@@ -241,8 +245,6 @@ style_edition = "2024"
241245
| checkstyle | emits in a checkstyle format | Yes |
242246
| json | emits diffs in a json format | Yes |
243247

244-
* When using `rustfmt` directly in a Cargo project, set the `style_edition` or `edition` in `rustfmt.toml` to the same value as in `Cargo.toml` to ensure consistent formatting. For more details, see the [Style Editions](#style-editions) and [Rust's Editions](#rusts-editions) sections.
245-
246248
## License
247249

248250
Rustfmt is distributed under the terms of both the MIT license and the

0 commit comments

Comments
 (0)