chore: clippy fixes

This commit is contained in:
Amaan Qureshi 2024-09-27 15:42:38 -04:00
parent b2359e4020
commit 90efa34608
12 changed files with 47 additions and 43 deletions

View file

@ -110,18 +110,16 @@ pub fn get_test_language(name: &str, parser_code: &str, path: Option<&Path>) ->
let header_path = src_dir.join("tree_sitter");
fs::create_dir_all(&header_path).unwrap();
[
for (file, content) in [
("alloc.h", ALLOC_HEADER),
("array.h", ARRAY_HEADER),
("parser.h", tree_sitter::PARSER_HEADER),
]
.iter()
.for_each(|(file, content)| {
] {
let file = header_path.join(file);
fs::write(&file, content)
.with_context(|| format!("Failed to write {:?}", file.file_name().unwrap()))
.unwrap();
});
}
let paths_to_check = if let Some(scanner_path) = &scanner_path {
vec![parser_path, scanner_path.clone()]

View file

@ -1391,7 +1391,7 @@ fn test_grammars_that_can_hang_on_eof() {
#[test]
fn test_parse_stack_recursive_merge_error_cost_calculation_bug() {
let source_code = r#"
let source_code = r"
fn main() {
if n == 1 {
} else if n == 2 {
@ -1404,7 +1404,7 @@ let y = if x == 5 { 10 } else { 15 };
if foo && bar {}
if foo && bar || baz {}
"#;
";
let mut parser = Parser::new();
parser.set_language(&get_language("rust")).unwrap();

View file

@ -3918,7 +3918,7 @@ fn test_query_random() {
.matches(
&query,
test_tree.root_node(),
(include_str!("parser_test.rs")).as_bytes(),
include_bytes!("parser_test.rs").as_ref(),
)
.map(|mat| Match {
last_node: None,
@ -5137,7 +5137,7 @@ fn test_query_wildcard_with_immediate_first_child() {
fn test_query_on_empty_source_code() {
let language = get_language("javascript");
let source_code = "";
let query = r#"(program) @program"#;
let query = "(program) @program";
let query = Query::new(&language, query).unwrap();
assert_query_matches(
&language,