horaedb icon indicating copy to clipboard operation
horaedb copied to clipboard

Formatter can't recognize newline missing

Open ShiKaiWi opened this issue 2 years ago • 4 comments

Description Now the rust formatter can't recognize the necessary newline missing, e.g.:

use crate::{
    instance::{Instance, InstanceRef},
    mysql::{error::*, worker::MysqlWorker},
};
pub struct MysqlService<C, Q> {

Make the formatter can fix this case.

Proposal No proposal yet.

Additional context

ShiKaiWi avatar Jun 24 '22 08:06 ShiKaiWi

There is a tracking issue in rustfmt:

  • https://github.com/rust-lang/rustfmt/issues/3382

jiacai2050 avatar Jun 28 '22 06:06 jiacai2050

current version of blank_lines_lower_bound is not what we want: https://rust-lang.github.io/rustfmt/?version=v1.5.0&search=#blank_lines_lower_bound

its example behavior is a bit wired

fn foo() {

    println!("a");
}

fn bar() {

    println!("b");

    println!("c");
}

waynexia avatar Jun 28 '22 06:06 waynexia

current version of blank_lines_lower_bound is not what we want

This comment says it's already been fixed in this https://github.com/rust-lang/rustfmt/pull/4295, just not released...

jiacai2050 avatar Jun 28 '22 06:06 jiacai2050

I think rust-lang/rustfmt#4295 is merged to the rustfmt-v2-rc branch, which is not going to release.

So the current release(rustfmt-v1) does not contain this patch.

rustfmt-v2 tracking issue: rust-lang/rustfmt#3887

ygf11 avatar Jun 28 '22 07:06 ygf11

Closing since this won't be fixed with rustfmt-v1

jiacai2050 avatar Mar 02 '23 13:03 jiacai2050