Skip to content

Commit aa9be4d

Browse files
committed
Use xshell::read_file instead of fs::read_to_string
1 parent 2a20e77 commit aa9be4d

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

xtask/src/codegen/gen_assists_docs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Generates `assists.md` documentation.
22
3-
use std::{fmt, fs, path::Path};
3+
use std::{fmt, path::Path};
44

55
use crate::{
66
codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE},
@@ -39,7 +39,7 @@ impl Assist {
3939
return Ok(res);
4040

4141
fn collect_file(acc: &mut Vec<Assist>, path: &Path) -> Result<()> {
42-
let text = fs::read_to_string(path)?;
42+
let text = xshell::read_file(path)?;
4343
let comment_blocks = extract_comment_blocks_with_empty_lines("Assist", &text);
4444

4545
for block in comment_blocks {

xtask/src/codegen/gen_diagnostic_docs.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
//! Generates `assists.md` documentation.
22
3-
use std::{fmt, fs, path::PathBuf};
3+
use std::{fmt, path::PathBuf};
44

55
use crate::{
66
codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
77
project_root, rust_files, Result,
88
};
99

1010
pub fn generate_diagnostic_docs(mode: Mode) -> Result<()> {
11-
let features = Diagnostic::collect()?;
12-
let contents = features.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
11+
let diagnostics = Diagnostic::collect()?;
12+
let contents =
13+
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
1314
let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim());
1415
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
1516
codegen::update(&dst, &contents, mode)?;
@@ -33,7 +34,7 @@ impl Diagnostic {
3334
return Ok(res);
3435

3536
fn collect_file(acc: &mut Vec<Diagnostic>, path: PathBuf) -> Result<()> {
36-
let text = fs::read_to_string(&path)?;
37+
let text = xshell::read_file(&path)?;
3738
let comment_blocks = extract_comment_blocks_with_empty_lines("Diagnostic", &text);
3839

3940
for block in comment_blocks {

xtask/src/codegen/gen_feature_docs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Generates `assists.md` documentation.
22
3-
use std::{fmt, fs, path::PathBuf};
3+
use std::{fmt, path::PathBuf};
44

55
use crate::{
66
codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
@@ -33,7 +33,7 @@ impl Feature {
3333
return Ok(res);
3434

3535
fn collect_file(acc: &mut Vec<Feature>, path: PathBuf) -> Result<()> {
36-
let text = fs::read_to_string(&path)?;
36+
let text = xshell::read_file(&path)?;
3737
let comment_blocks = extract_comment_blocks_with_empty_lines("Feature", &text);
3838

3939
for block in comment_blocks {

xtask/src/codegen/gen_parser_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn existing_tests(dir: &Path, ok: bool) -> Result<HashMap<String, (PathBuf, Test
124124
let file_name = path.file_name().unwrap().to_str().unwrap();
125125
file_name[5..file_name.len() - 3].to_string()
126126
};
127-
let text = fs::read_to_string(&path)?;
127+
let text = xshell::read_file(&path)?;
128128
let test = Test { name: name.clone(), text, ok };
129129
if let Some(old) = res.insert(name, (path, test)) {
130130
println!("Duplicate test: {:?}", old);

0 commit comments

Comments
 (0)