rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

`rustfmt` leaves an extra space after `self` in function signature

Open TimeEngineer opened this issue 2 years ago • 4 comments

impl Foo {
    fn foo(
        &self,

        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: i32,
    ) -> Self {
        Self
    }
}

should be formatted into

impl Foo {
    fn foo(
        &self,
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: i32,
    ) -> Self {
        Self
    }
}

TimeEngineer avatar Jul 20 '23 15:07 TimeEngineer

I think this issue is related to #245. Does anyone know whether the extra blank line is expected or not in the default setting of rustfmt?

yichi170 avatar Jul 23 '23 17:07 yichi170

@rustbot claim

raheja15 avatar Mar 12 '24 19:03 raheja15

In my humble opinion, it is expected to have a blank line. If we do not have a blank line, it may also remove the comment in between the lines. Also, if we have more than 1 line, Rustfmt is correctly reducing it to one blank line.

Also, it might be helpful to have a blank line in between the parameters sometimes to enhance the readability of the code.

raheja15 avatar Mar 13 '24 18:03 raheja15

@raheja15 It's my expectation that the blank line would be removed. Could you elaborate on your explanation with some example code snippets. Are you saying that you tried to make code changes that resulted in incorrect formatting for other code snippets?

ytmimi avatar Mar 13 '24 18:03 ytmimi