From 2c4cfb297ec59625310023796b65e3dd48f1e76a Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Tue, 16 Oct 2018 15:36:53 +0600 Subject: take `&Path` instead of `PathBuf` --- crates/tools/src/lib.rs | 2 +- crates/tools/src/main.rs | 4 ++-- crates/tools/tests/cli.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index 548b157dd..9a1b12a16 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -77,7 +77,7 @@ pub fn update(path: &Path, contents: &str, verify: bool) -> Result<()> { Ok(()) } -pub fn render_template(template: PathBuf) -> Result { +pub fn render_template(template: &Path) -> Result { let grammar: ron::value::Value = { let text = fs::read_to_string(project_root().join(GRAMMAR))?; ron::de::from_str(&text)? diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 549892bc6..6eacfc190 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs @@ -40,8 +40,8 @@ fn main() -> Result<()> { fn run_gen_command(name: &str, verify: bool) -> Result<()> { match name { "gen-kinds" => { - update(&project_root().join(SYNTAX_KINDS), &render_template(project_root().join(SYNTAX_KINDS_TEMPLATE))?, verify)?; - update(&project_root().join(AST), &render_template(project_root().join(AST_TEMPLATE))?, verify)?; + update(&project_root().join(SYNTAX_KINDS), &render_template(&project_root().join(SYNTAX_KINDS_TEMPLATE))?, verify)?; + update(&project_root().join(AST), &render_template(&project_root().join(AST_TEMPLATE))?, verify)?; }, "gen-tests" => { gen_tests(verify)? diff --git a/crates/tools/tests/cli.rs b/crates/tools/tests/cli.rs index d0ed60f7a..f507d80a2 100644 --- a/crates/tools/tests/cli.rs +++ b/crates/tools/tests/cli.rs @@ -4,10 +4,10 @@ use tools::{AST, AST_TEMPLATE, SYNTAX_KINDS, SYNTAX_KINDS_TEMPLATE, render_templ #[test] fn verify_template_generation() { - if let Err(error) = update(&project_root().join(SYNTAX_KINDS), &render_template(project_root().join(SYNTAX_KINDS_TEMPLATE)).unwrap(), true) { + if let Err(error) = update(&project_root().join(SYNTAX_KINDS), &render_template(&project_root().join(SYNTAX_KINDS_TEMPLATE)).unwrap(), true) { panic!("{}. Please update it by running `cargo gen-kinds`", error); } - if let Err(error) = update(&project_root().join(AST), &render_template(project_root().join(AST_TEMPLATE)).unwrap(), true) { + if let Err(error) = update(&project_root().join(AST), &render_template(&project_root().join(AST_TEMPLATE)).unwrap(), true) { panic!("{}. Please update it by running `cargo gen-kinds`", error); } } -- cgit v1.2.3