Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jstarks opened this issue Nov 23, 2019 · 4 comments
Closed

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

jstarks opened this issue Nov 23, 2019 · 4 comments

Comments

@jstarks
Copy link

jstarks commented Nov 23, 2019

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
@calebcartwright
Copy link
Member

What version of rustfmt are you using?

@jstarks
Copy link
Author

jstarks commented Nov 23, 2019

Oops, sorry. This repros with both:
rustfmt 1.4.8-stable (afb1ee1 2019-09-08)
and:
rustfmt 1.4.9-nightly (33e3667 2019-10-07)

@calebcartwright
Copy link
Member

Thanks @jstarks - believe this is fixed in 1.4.10 via #3850

@jstarks
Copy link
Author

jstarks commented Nov 23, 2019

Ah ha, you're right, confirmed. Closing. Thanks!

@jstarks jstarks closed this as completed Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants