rust-lang / rust-lang/rustfmt

Last parameter in function signature misaligned

Open
#4,352 1 comment 0 reactions 1 assignee View on GitHub

@topecongiro is already working on this.

Since Jul 26, 2020.

I-poor-formatting only-with-option
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

When using Visual indent style and formatting a multi-lined function signature with the first line exceeding max_width, the last parameter will be formatted with incorrect indentation

Input

rustfmt.toml

indent_style = "Visual"
# This can be anything, just using a shorter value than the default for an easier example
max_width = 30
fn exceeds_max_width_1<T: Foo>(
    a: T,
    b: u32,
    c: u32){
   
}

Output

fn exceeds_max_width_1<T: Foo>(
    a: T,
    b: u32,
c: u32){
    // ...
}

Expected output
Believe it should be something like the below, but either way the indentation of the c parameter is definitely off currently

fn exceeds_max_width_1<
    T: Foo,
>(
    a: T,
    b: u32,
    c: u32,
){
    // ...
}

Meta

  • rustfmt version: Can reproduce this with 1.4.19 and latest 2.0 version on master
  • From where did you install rustfmt?: Tested building from source as well as via rustup on nightly

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.