rustfmt
rustfmt copied to clipboard
Format Rust code
… a function arg. fixes #6520 A bit unsure about this one. The problem is that if you have a comment that spans to the end of the line, then...
Context: When `reorder_imports = true`, rustfmt mixes `pub` imports in with private imports. Please add an option to put pub imports (aka exports) before normal imports. IMO it's not idiomatic...
The following code fragment: ```rust fn sanity_check( path: &Utf8Path, style: Style, chezmoi: &impl Chezmoi, ) -> Result { if !path.is_file() { return Err(anyhow!("{} is not a regular file", path)); }...
Fixes #6568 When using `style_edition=2024` trailing whitespace was not properly removed when foramtting same line comments.
With the following code: ```rust trait Foo { fn fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(_: ()) -> u32; } ``` The `->` is indented with 4 spaces after `fn` with edition 2021, but with edition...
## Description It should be safe to remove unnecessarily nested blocks when there's no statements in between: `{{{ }}} => { }`. ## Example Input: ```rust fn f() { {{{{{...
Take the following Rust code: ```rust fn main() { println!("Hello, world!"); } macro_rules! trigger { (KeyBinding, $key:literal, $location:expr) => {{ BindingKey::Keycode { key: Key::Character($key.into()), location: $location } }}; (KeyBinding, $key:literal,)...
```rust macro_rules! val { ($name:ident) => { stringify!($name) }; // ($name:ident $value:literal) => { // $value // }; } ``` gets formatted as ```rust macro_rules! val { ($name:ident) => {...
### System/Tool Info - Ubuntu 22.04. - Rust 2024 edition. ``` rustup toolchain list stable-x86_64-unknown-linux-gnu (default) 1.85.1-x86_64-unknown-linux-gnu 1.86.0-x86_64-unknown-linux-gnu (active) cargo fmt --version rustfmt 1.8.0-stable (05f9846f89 2025-03-31) cargo --version cargo 1.86.0...
When a comment ends with a trailing whitespace, `cargo fmt --check` gives an unclear error message. ```rust fn main() { // Comment with trailing whitespace println!("Hello world"); } ``` Error...