Skip to content

Newline style changes to Unix-style when file is modified #4097

@ajtribick

Description

@ajtribick

On Windows, using the default newline style (either without rustfmt.toml or by explicitly setting newline_style="Auto":

  • leaves the newlines intact if the file does not have any formatting issues (ok, expected)
  • saves modified files with Unix-style endings, even when all line-breaks in the input file are CRLF.

I would expect that in such cases the "Auto" value would use the line-break style inferred from examining the file.

Version used: rustfmt 1.4.11-stable (9eb4b564 2020-01-29)
as invoked via the cargo fmt command, version cargo 1.42.0 (86334295e 2020-01-31)

It's possible to work around this by forcing "Native" style in the rustfmt.toml but the default behaviour results in a mixture of line-ending styles throughout the project and triggers git line-ending conversion warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1x-backport:pendingFixed/resolved in source but not yet backported to a 1x branch and release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions