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

Fix --check -l with stdin. #3910

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix some possible panics when using --check with stdin.
One case which doesn't work is when there are only line ending fixes;
with stdin rustfmt is unable to detect the difference as it stores
the input with Unix line endings.
  • Loading branch information
jugglerchris committed Nov 7, 2019
commit 8279a9cf4e2ef40b63dfc279e44607e5962ddbeb
5 changes: 2 additions & 3 deletions src/emitter/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,7 @@ impl Emitter for DiffEmitter {

if has_diff {
if self.config.print_misformatted_file_names() {
writeln!(output, "{}", ensure_real_path(filename).display())?;
writeln!(output, "{}", filename)?;
} else {
print_diff(
mismatch,
Expand All @@ -40,8 40,7 @@ impl Emitter for DiffEmitter {
// This occurs when the only difference between the original and formatted values
// is the newline style. This happens because The make_diff function compares the
// original and formatted values line by line, independent of line endings.
let file_path = ensure_real_path(filename);
writeln!(output, "Incorrect newline style in {}", file_path.display())?;
writeln!(output, "Incorrect newline style in {}", filename)?;
return Ok(EmitterResult { has_diff: true });
}

Expand Down