mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
take &Path
instead of PathBuf
This commit is contained in:
parent
9d9e637ef3
commit
2c4cfb297e
3 changed files with 5 additions and 5 deletions
|
@ -77,7 +77,7 @@ pub fn update(path: &Path, contents: &str, verify: bool) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn render_template(template: PathBuf) -> Result<String> {
|
||||
pub fn render_template(template: &Path) -> Result<String> {
|
||||
let grammar: ron::value::Value = {
|
||||
let text = fs::read_to_string(project_root().join(GRAMMAR))?;
|
||||
ron::de::from_str(&text)?
|
||||
|
|
|
@ -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)?
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue