Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorder_impl_items doesn't maintain newlines #4882

Open
TornaxO7 opened this issue Jun 25, 2021 · 1 comment
Open

reorder_impl_items doesn't maintain newlines #4882

TornaxO7 opened this issue Jun 25, 2021 · 1 comment
Labels
only-with-option requires a non-default option value to reproduce p-low

Comments

@TornaxO7
Copy link

TornaxO7 commented Jun 25, 2021

Reproduction information

Example code:

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:

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:

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:

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

@calebcartwright calebcartwright added the only-with-option requires a non-default option value to reproduce label Jul 5, 2021
@calebcartwright calebcartwright changed the title reorder_impl_items formats impl wrong reorder_impl_items doesn't maintain newlines Jul 5, 2021
@ytmimi
Copy link
Contributor

ytmimi commented Jul 26, 2022

Linking tracking issue for reorder_impl_items #3363

@ytmimi ytmimi added the p-low label Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
only-with-option requires a non-default option value to reproduce p-low
Projects
None yet
Development

No branches or pull requests

3 participants