Skip to content

newline_style = "Unix" has no effect for unchanged files #3939

@jstarks

Description

@jstarks

I have a project where many files have Windows line endings. I set newline_style to Unix and ran cargo fmt, expecting the files to be reformatted, but they are not unless there is some other non-line-ending change being made.

Interestingly, the opposite is not true: if I explicitly set newline_style to Windows, then any Unix-formatted files are rewritten even if there is no other reformatting to do.

To repro this:

cargo init
git add .
cargo fmt -- --config newline_style=Windows
git diff # see that src/main.rs has been reformatted with Windows line endings
git add -u
cargo fmt -- --config newline_style=Unix
git diff # see that there are no changes--src/main.rs still has Windows line endings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions