mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Show how to generate code with error message
This commit is contained in:
parent
114e9a2d74
commit
33b378797c
3 changed files with 8 additions and 6 deletions
|
@ -13,7 +13,7 @@ use std::{
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
|
use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
|
||||||
|
|
||||||
type Result<T> = ::std::result::Result<T, failure::Error>;
|
pub type Result<T> = ::std::result::Result<T, failure::Error>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Test {
|
pub struct Test {
|
||||||
|
|
|
@ -11,9 +11,7 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
use tools::{Test, collect_tests, render_template, update};
|
use tools::{Test, collect_tests, render_template, update, Result};
|
||||||
|
|
||||||
type Result<T> = ::std::result::Result<T, failure::Error>;
|
|
||||||
|
|
||||||
const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar";
|
const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar";
|
||||||
const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline";
|
const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline";
|
||||||
|
|
|
@ -11,6 +11,10 @@ const AST_TEMPLATE: &str = "../ra_syntax/src/ast/generated.rs.tera";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn verify_template_generation() {
|
fn verify_template_generation() {
|
||||||
update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE, GRAMMAR).unwrap(), true).unwrap();
|
if let Err(error) = update(Path::new(SYNTAX_KINDS), &render_template(SYNTAX_KINDS_TEMPLATE, GRAMMAR).unwrap(), true) {
|
||||||
update(Path::new(AST), &render_template(AST_TEMPLATE, GRAMMAR).unwrap(), true).unwrap();
|
panic!("{}. Please update it by running `cargo gen-kinds`", error);
|
||||||
|
}
|
||||||
|
if let Err(error) = update(Path::new(AST), &render_template(AST_TEMPLATE, GRAMMAR).unwrap(), true) {
|
||||||
|
panic!("{}. Please update it by running `cargo gen-kinds`", error);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue