rust-lang / rust-lang/rustfmt

blank_lines_lower_bound ignores impl/traits functions

Open
#5,067 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug only-with-option P-low UO-blank_lines_lower_bound
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Version: rustfmt 2.0.0-rc.2-nightly (cc5521d9 2021-10-23)
rustfmt.toml:

tab_spaces = 2
blank_lines_lower_bound = 1

Before

fn a() {}
fn b() {}
mod foo {
  fn a() {}
  fn b() {}
}
struct Foo;
impl Foo {
  fn a() {}
  fn b() {}
}
trait Bar {
  fn a();
  fn b();
}

After (currently)

fn a() {}

fn b() {}

mod foo {

  fn a() {}

  fn b() {}
}

struct Foo;

impl Foo {
  fn a() {}
  fn b() {}
}

trait Bar {
  fn a();
  fn b();
}

After (what I think it should be formatted as)

fn a() {}

fn b() {}

mod foo {
  fn a() {}

  fn b() {}
}

struct Foo;

impl Foo {
  fn a() {}

  fn b() {}
}

trait Bar {
  fn a();
  
  fn b();
}

Related to #2954, also would be nice to have this https://github.com/rust-lang/rustfmt/issues/3382#issuecomment-793084299

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running rustfmt with the shown rustfmt.toml settings against the Before example and compare the output with the requested formatting. Trace the blank_lines_lower_bound handling for functions inside mod, impl, and trait blocks; done means those functions receive the configured separation without changing the other demonstrated formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.