Skip to content

Commit 3d3e1b3

Browse files
committed
Handle Windows newlines.
Suggestions that come from rustc that are multi-line only use LF line endings. But if the file is checked out on windows with CRLF line-endings, then you end up with a mix of line endings that don't match the "fixed.rs" file. Tracking this at rust-lang/rust#119482.
1 parent a21997f commit 3d3e1b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/rustfix/tests/parse_and_replace.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
174174
}
175175

176176
let fixed = apply_suggestions(&code, &suggestions)
177-
.context(format!("could not apply suggestions to {}", file.display()))?;
177+
.context(format!("could not apply suggestions to {}", file.display()))?
178+
.replace('\r', "");
178179

179180
if std::env::var(settings::RECORD_FIXED_RUST).is_ok() {
180181
fs::write(file.with_extension("recorded.rs"), &fixed)?;
@@ -188,7 +189,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
188189
}
189190

190191
let expected_fixed = fs::read_to_string(&fixed_file)
191-
.context(format!("could read fixed file for {}", file.display()))?;
192+
.context(format!("could read fixed file for {}", file.display()))?
193+
.replace('\r', "");
192194
ensure!(
193195
fixed.trim() == expected_fixed.trim(),
194196
"file {} doesn't look fixed:\n{}",

0 commit comments

Comments
 (0)