aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-06 09:41:33 +0000
committerGitHub <[email protected]>2019-11-06 09:41:33 +0000
commitd222608a45d53ca7a1bbc9f0126a092fda48503c (patch)
tree0254b248a3d4faa09677287746ec58cbf01bc512
parent4fbb36db9b4e7b3416daccc6b9a62f97ae12d6a3 (diff)
parent5efd99a6e0a229d40106811188f6afd58dd97399 (diff)
Merge #2188
2188: Ignore line-endings when checking generated files for freshness r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--xtask/src/codegen.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index 4ec8ab75a..770b55a9a 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -46,7 +46,7 @@ pub enum Mode {
46/// With verify = false, 46/// With verify = false,
47fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { 47fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
48 match fs::read_to_string(path) { 48 match fs::read_to_string(path) {
49 Ok(ref old_contents) if old_contents == contents => { 49 Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => {
50 return Ok(()); 50 return Ok(());
51 } 51 }
52 _ => (), 52 _ => (),
@@ -56,7 +56,11 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
56 } 56 }
57 eprintln!("updating {}", path.display()); 57 eprintln!("updating {}", path.display());
58 fs::write(path, contents)?; 58 fs::write(path, contents)?;
59 Ok(()) 59 return Ok(());
60
61 fn normalize(s: &str) -> String {
62 s.replace("\r\n", "\n")
63 }
60} 64}
61 65
62fn reformat(text: impl std::fmt::Display) -> Result<String> { 66fn reformat(text: impl std::fmt::Display) -> Result<String> {