rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
5.96k stars 879 forks source link

reorder_impl_items doesn't maintain newlines #4882

Open TornaxO7 opened 3 years ago

TornaxO7 commented 3 years ago

Reproduction information

Example code:

```rust pub struct BeautifulStruct; impl BeautifulStruct { /// Another awesome doc const LMAO: i32 = 42; /// Awesome doc const ROFL: i32 = 10; } fn main() { println!("Hello, world!"); } ```

Content of ~/.config/rusfmt/rustfmt.toml:

```toml reorder_impl_items = true ```

Output of rustfmt -V: rustfmt 1.4.37-nightly (7c3872e 2021-06-24)

Problem

If I run rustfmt with the settings and the file above, rustfmt changes the file to this:

```rust pub struct BeautifulStruct; impl BeautifulStruct { /// Another awesome doc const LMAO: i32 = 42; /// Awesome doc const ROFL: i32 = 10; } fn main() { println!("Hello, world!"); } ```

But I'd expect to be like this:

```rust pub struct BeautifulStruct; impl BeautifulStruct { /// Another awesome doc const LMAO: i32 = 42; /// Awesome doc const ROFL: i32 = 10; } fn main() { println!("Hello, world!"); } ```

If you don't see the difference: There's a blank line between const LMAO: i32 = 42; and the documentation paragraph /// Awesome doc in my "expectation-example".

ytmimi commented 2 years ago

Linking tracking issue for reorder_impl_items #3363