Rustfmt: [unstable option] blank_lines_lower_bound

Created on 13 Feb 2019  路  4Comments  路  Source: rust-lang/rustfmt

Tracking issue for blank_lines_lower_bound

unstable option

Most helpful comment

It would be more useful if statements inside functions are not covered by this, only declarations!

Or is there another way to specify that I want to have at least 1 empty line between declarations (also between function-local declarations and whatever comes before/after)? (But not between statements in a function body.)

Example
Original Code (rustfmt will not change it with the default value of 0):

const A: u32 = 1;
enum B {
    C
}
impl B {
    // ...
}

Set to 1:

const A: u32 = 1;

enum B {
    C
}

impl B {
    // ...
}

All 4 comments

It would be more useful if statements inside functions are not covered by this, only declarations!

Or is there another way to specify that I want to have at least 1 empty line between declarations (also between function-local declarations and whatever comes before/after)? (But not between statements in a function body.)

Example
Original Code (rustfmt will not change it with the default value of 0):

const A: u32 = 1;
enum B {
    C
}
impl B {
    // ...
}

Set to 1:

const A: u32 = 1;

enum B {
    C
}

impl B {
    // ...
}

What are the issues blocking the stabilisation of this option?

@arzg - The process and requirements for stabilizing a configuration option are described here. Specifically, there are several issues that exist with blank_lines_lower_bound in released versions of rustfmt (1.x versions), for example https://github.com/rust-lang/rustfmt/issues/2954.

Some fixes/improvements to blank_lines_lower_bound have been made within the rustfmt source, but they have not yet been released. As such there are at least two stabilization requirements not yet for this configuration option:

  • The design and implementation of the option are sound and clean.
  • The option is well tested, both in unit tests and, optimally, in real usage.

With blank_lines_lower_bound set to 0, rustfmt (1.4.27-nightly (580d826e 2020-11-16)) will still insert blank lines between fns, for example

impl A {
    fn a() { /* ... */ }
    fn b() { /* ... */ }
}

will get formatted to

impl A {
    fn a() { /* ... */ }

    fn b() { /* ... */ }
}

Is this correct? I.e., should this case be covered by this configuration option?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fuine picture fuine  路  3Comments

Julian-Wollersberger picture Julian-Wollersberger  路  5Comments

LPGhatguy picture LPGhatguy  路  3Comments

alatiera picture alatiera  路  4Comments

tkilbourn picture tkilbourn  路  5Comments