diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 4ec8ab75af..770b55a9ac 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -46,7 +46,7 @@ pub enum Mode { /// With verify = false, fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { match fs::read_to_string(path) { - Ok(ref old_contents) if old_contents == contents => { + Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => { return Ok(()); } _ => (), @@ -56,7 +56,11 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { } eprintln!("updating {}", path.display()); fs::write(path, contents)?; - Ok(()) + return Ok(()); + + fn normalize(s: &str) -> String { + s.replace("\r\n", "\n") + } } fn reformat(text: impl std::fmt::Display) -> Result {