Skip to content

Commit 9b16ae5

Browse files
bors[bot]Veetaha
andauthored
Merge #4033
4033: Refactor codegen r=matklad a=Veetaha Co-authored-by: veetaha <[email protected]>
2 parents 6f60e64 + 21b98d5 commit 9b16ae5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

xtask/src/codegen.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ mod gen_syntax;
99
mod gen_parser_tests;
1010
mod gen_assists_docs;
1111

12-
use std::{fs, mem, path::Path};
12+
use std::{mem, path::Path};
1313

14-
use crate::Result;
14+
use crate::{not_bash::fs2, Result};
1515

1616
pub use self::{
1717
gen_assists_docs::generate_assists_docs, gen_parser_tests::generate_parser_tests,
@@ -39,7 +39,7 @@ pub enum Mode {
3939
/// A helper to update file on disk if it has changed.
4040
/// With verify = false,
4141
fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
42-
match fs::read_to_string(path) {
42+
match fs2::read_to_string(path) {
4343
Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => {
4444
return Ok(());
4545
}
@@ -49,7 +49,7 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
4949
anyhow::bail!("`{}` is not up-to-date", path.display());
5050
}
5151
eprintln!("updating {}", path.display());
52-
fs::write(path, contents)?;
52+
fs2::write(path, contents)?;
5353
return Ok(());
5454

5555
fn normalize(s: &str) -> String {
@@ -65,15 +65,15 @@ fn extract_comment_blocks_with_empty_lines(text: &str) -> Vec<Vec<String>> {
6565
do_extract_comment_blocks(text, true)
6666
}
6767

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>> {
6969
let mut res = Vec::new();
7070

7171
let prefix = "// ";
7272
let lines = text.lines().map(str::trim_start);
7373

7474
let mut block = vec![];
7575
for line in lines {
76-
if line == "//" && allow_blocks_with_empty_lins {
76+
if line == "//" && allow_blocks_with_empty_lines {
7777
block.push(String::new());
7878
continue;
7979
}

0 commit comments

Comments
 (0)