diff options
Diffstat (limited to 'xtask/src/codegen.rs')
-rw-r--r-- | xtask/src/codegen.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 678b40133..0e4dcb95a 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs | |||
@@ -9,9 +9,9 @@ mod gen_syntax; | |||
9 | mod gen_parser_tests; | 9 | mod gen_parser_tests; |
10 | mod gen_assists_docs; | 10 | mod gen_assists_docs; |
11 | 11 | ||
12 | use std::{fs, mem, path::Path}; | 12 | use std::{mem, path::Path}; |
13 | 13 | ||
14 | use crate::Result; | 14 | use crate::{not_bash::fs2, Result}; |
15 | 15 | ||
16 | pub use self::{ | 16 | pub use self::{ |
17 | gen_assists_docs::generate_assists_docs, gen_parser_tests::generate_parser_tests, | 17 | gen_assists_docs::generate_assists_docs, gen_parser_tests::generate_parser_tests, |
@@ -39,7 +39,7 @@ pub enum Mode { | |||
39 | /// A helper to update file on disk if it has changed. | 39 | /// A helper to update file on disk if it has changed. |
40 | /// With verify = false, | 40 | /// With verify = false, |
41 | fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { | 41 | fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { |
42 | match fs::read_to_string(path) { | 42 | match fs2::read_to_string(path) { |
43 | Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => { | 43 | Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => { |
44 | return Ok(()); | 44 | return Ok(()); |
45 | } | 45 | } |
@@ -49,7 +49,7 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { | |||
49 | anyhow::bail!("`{}` is not up-to-date", path.display()); | 49 | anyhow::bail!("`{}` is not up-to-date", path.display()); |
50 | } | 50 | } |
51 | eprintln!("updating {}", path.display()); | 51 | eprintln!("updating {}", path.display()); |
52 | fs::write(path, contents)?; | 52 | fs2::write(path, contents)?; |
53 | return Ok(()); | 53 | return Ok(()); |
54 | 54 | ||
55 | fn normalize(s: &str) -> String { | 55 | fn normalize(s: &str) -> String { |
@@ -65,7 +65,7 @@ fn extract_comment_blocks_with_empty_lines(text: &str) -> Vec<Vec<String>> { | |||
65 | do_extract_comment_blocks(text, true) | 65 | do_extract_comment_blocks(text, true) |
66 | } | 66 | } |
67 | 67 | ||
68 | fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lins: bool) -> Vec<Vec<String>> { | 68 | fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) -> Vec<Vec<String>> { |
69 | let mut res = Vec::new(); | 69 | let mut res = Vec::new(); |
70 | 70 | ||
71 | let prefix = "// "; | 71 | let prefix = "// "; |
@@ -73,7 +73,7 @@ fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lins: bool) -> | |||
73 | 73 | ||
74 | let mut block = vec![]; | 74 | let mut block = vec![]; |
75 | for line in lines { | 75 | for line in lines { |
76 | if line == "//" && allow_blocks_with_empty_lins { | 76 | if line == "//" && allow_blocks_with_empty_lines { |
77 | block.push(String::new()); | 77 | block.push(String::new()); |
78 | continue; | 78 | continue; |
79 | } | 79 | } |