From aa9be4d5232f27d285211c0c880259655316d114 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Mon, 19 Oct 2020 20:58:32 +0300 Subject: Use xshell::read_file instead of fs::read_to_string --- xtask/src/codegen/gen_assists_docs.rs | 4 ++-- xtask/src/codegen/gen_diagnostic_docs.rs | 9 +++++---- xtask/src/codegen/gen_feature_docs.rs | 4 ++-- xtask/src/codegen/gen_parser_tests.rs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index ff307e2aa..d7c85ebe9 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs @@ -1,6 +1,6 @@ //! Generates `assists.md` documentation. -use std::{fmt, fs, path::Path}; +use std::{fmt, path::Path}; use crate::{ codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE}, @@ -39,7 +39,7 @@ impl Assist { return Ok(res); fn collect_file(acc: &mut Vec, path: &Path) -> Result<()> { - let text = fs::read_to_string(path)?; + let text = xshell::read_file(path)?; let comment_blocks = extract_comment_blocks_with_empty_lines("Assist", &text); for block in comment_blocks { diff --git a/xtask/src/codegen/gen_diagnostic_docs.rs b/xtask/src/codegen/gen_diagnostic_docs.rs index 4d630ce8c..00aaea5b7 100644 --- a/xtask/src/codegen/gen_diagnostic_docs.rs +++ b/xtask/src/codegen/gen_diagnostic_docs.rs @@ -1,6 +1,6 @@ //! Generates `assists.md` documentation. -use std::{fmt, fs, path::PathBuf}; +use std::{fmt, path::PathBuf}; use crate::{ codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE}, @@ -8,8 +8,9 @@ use crate::{ }; pub fn generate_diagnostic_docs(mode: Mode) -> Result<()> { - let features = Diagnostic::collect()?; - let contents = features.into_iter().map(|it| it.to_string()).collect::>().join("\n\n"); + let diagnostics = Diagnostic::collect()?; + let contents = + diagnostics.into_iter().map(|it| it.to_string()).collect::>().join("\n\n"); let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim()); let dst = project_root().join("docs/user/generated_diagnostic.adoc"); codegen::update(&dst, &contents, mode)?; @@ -33,7 +34,7 @@ impl Diagnostic { return Ok(res); fn collect_file(acc: &mut Vec, path: PathBuf) -> Result<()> { - let text = fs::read_to_string(&path)?; + let text = xshell::read_file(&path)?; let comment_blocks = extract_comment_blocks_with_empty_lines("Diagnostic", &text); for block in comment_blocks { diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs index 341e67c73..065dd33f1 100644 --- a/xtask/src/codegen/gen_feature_docs.rs +++ b/xtask/src/codegen/gen_feature_docs.rs @@ -1,6 +1,6 @@ //! Generates `assists.md` documentation. -use std::{fmt, fs, path::PathBuf}; +use std::{fmt, path::PathBuf}; use crate::{ codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE}, @@ -33,7 +33,7 @@ impl Feature { return Ok(res); fn collect_file(acc: &mut Vec, path: PathBuf) -> Result<()> { - let text = fs::read_to_string(&path)?; + let text = xshell::read_file(&path)?; let comment_blocks = extract_comment_blocks_with_empty_lines("Feature", &text); for block in comment_blocks { diff --git a/xtask/src/codegen/gen_parser_tests.rs b/xtask/src/codegen/gen_parser_tests.rs index 96fdd9216..19ae949d4 100644 --- a/xtask/src/codegen/gen_parser_tests.rs +++ b/xtask/src/codegen/gen_parser_tests.rs @@ -124,7 +124,7 @@ fn existing_tests(dir: &Path, ok: bool) -> Result