Skip to content

rustfmt fails to remove trailing whitespace when next line is a comment before value #4427

Closed
@197g

Description

@197g

Describe the bug

cargo fmt fails with:

error[internal]: left behind trailing whitespace
 --> /tmp/cargo-fmt-fail/src/lib.rs:1:1:16
  |
1 | const A: usize = 
  |                 ^
  |

warning: rustfmt has failed to format. See previous 1 errors.

To Reproduce

Copy and paste this into a new source file (note the trailing whitespace in first line):

const A: usize = 
    // Some constant
    2;

Expected behavior

Meta

  • rustfmt version: rustfmt 1.4.18-stable (8157a3f 2020-07-15)
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: cargo fmt, rustfmt

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-commentsbugPanic, non-idempotency, invalid code, etc.good first issueIssues up for grabs, also good candidates for new rustfmt contributorshacktoberfesthelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions