remove fragments from syntax

This commit is contained in:
Aleksey Kladov 2021-12-27 21:34:39 +03:00
parent dacbc6a69a
commit 55f1564101
20 changed files with 0 additions and 98 deletions

View file

@ -180,13 +180,6 @@ impl ast::Path {
}
}
impl ast::Pat {
/// Returns `text`, parsed as a pattern, but only if it has no errors.
pub fn parse(text: &str) -> Result<Self, ()> {
parsing::parse_text_as(text, parser::ParserEntryPoint::Pattern)
}
}
impl ast::Expr {
/// Returns `text`, parsed as an expression, but only if it has no errors.
pub fn parse(text: &str) -> Result<Self, ()> {

View file

@ -59,24 +59,6 @@ fn validation_tests() {
});
}
#[test]
fn path_parser_tests() {
fragment_parser_dir_test(
&["parser/fragments/path/ok"],
&["parser/fragments/path/err"],
crate::ast::Path::parse,
);
}
#[test]
fn pattern_parser_tests() {
fragment_parser_dir_test(
&["parser/fragments/pattern/ok"],
&["parser/fragments/pattern/err"],
crate::ast::Pat::parse,
);
}
#[test]
fn parser_fuzz_tests() {
for (_, text) in collect_rust_files(&test_data_dir(), &["parser/fuzz-failures"]) {
@ -136,24 +118,6 @@ fn assert_errors_are_present(errors: &[SyntaxError], path: &Path) {
assert!(!errors.is_empty(), "There should be errors in the file {:?}", path.display());
}
fn fragment_parser_dir_test<T, F>(ok_paths: &[&str], err_paths: &[&str], f: F)
where
T: crate::AstNode,
F: Fn(&str) -> Result<T, ()>,
{
dir_tests(&test_data_dir(), ok_paths, "rast", |text, path| match f(text) {
Ok(node) => format!("{:#?}", crate::ast::AstNode::syntax(&node)),
Err(_) => panic!("Failed to parse '{:?}'", path),
});
dir_tests(&test_data_dir(), err_paths, "rast", |text, path| {
if f(text).is_ok() {
panic!("'{:?}' successfully parsed when it should have errored", path);
} else {
"ERROR\n".to_owned()
}
});
}
/// Calls callback `f` with input code and file paths for each `.rs` file in `test_data_dir`
/// subdirectories defined by `paths`.
///