chore: clippy

This commit is contained in:
dundargoc 2024-02-06 23:18:27 +01:00 committed by Amaan Qureshi
parent a1870b6013
commit c8bd6705cf
No known key found for this signature in database
GPG key ID: E67890ADC4227273
36 changed files with 467 additions and 462 deletions

View file

@ -20,12 +20,12 @@ where
parser.set_language(&language).unwrap();
let tree = parser.parse_with(callback, None).unwrap();
// eprintln!("{}", tree.clone().root_node().to_sexp());
assert_eq!("comment", tree.clone().root_node().child(0).unwrap().kind());
assert_eq!("comment", tree.root_node().child(0).unwrap().kind());
(tree, language)
}
fn tree_query<I: AsRef<[u8]>>(tree: &Tree, text: impl TextProvider<I>, language: Language) {
let query = Query::new(&language, "((comment) @c (#eq? @c \"// comment\"))").unwrap();
fn tree_query<I: AsRef<[u8]>>(tree: &Tree, text: impl TextProvider<I>, language: &Language) {
let query = Query::new(language, "((comment) @c (#eq? @c \"// comment\"))").unwrap();
let mut cursor = QueryCursor::new();
let mut captures = cursor.captures(&query, tree.root_node(), text);
let (match_, idx) = captures.next().unwrap();
@ -39,7 +39,7 @@ fn check_parsing<I: AsRef<[u8]>>(
text_provider: impl TextProvider<I>,
) {
let (tree, language) = parse_text(parser_text);
tree_query(&tree, text_provider, language);
tree_query(&tree, text_provider, &language);
}
fn check_parsing_callback<T, F, I: AsRef<[u8]>>(
@ -50,7 +50,7 @@ fn check_parsing_callback<T, F, I: AsRef<[u8]>>(
F: FnMut(usize, Point) -> T,
{
let (tree, language) = parse_text_with(parser_callback);
tree_query(&tree, text_provider, language);
tree_query(&tree, text_provider, &language);
}
#[test]
@ -114,7 +114,7 @@ fn test_text_provider_callback_with_str_slice() {
check_parsing_callback(
&mut |offset, _point| {
(offset < text.len())
.then(|| text.as_bytes())
.then_some(text.as_bytes())
.unwrap_or_default()
},
|_node: Node<'_>| iter::once(text),
@ -128,7 +128,7 @@ fn test_text_provider_callback_with_owned_string_slice() {
check_parsing_callback(
&mut |offset, _point| {
(offset < text.len())
.then(|| text.as_bytes())
.then_some(text.as_bytes())
.unwrap_or_default()
},
|_node: Node<'_>| {
@ -145,7 +145,7 @@ fn test_text_provider_callback_with_owned_bytes_vec_slice() {
check_parsing_callback(
&mut |offset, _point| {
(offset < text.len())
.then(|| text.as_bytes())
.then_some(text.as_bytes())
.unwrap_or_default()
},
|_node: Node<'_>| {
@ -162,7 +162,7 @@ fn test_text_provider_callback_with_owned_arc_of_bytes_slice() {
check_parsing_callback(
&mut |offset, _point| {
(offset < text.len())
.then(|| text.as_bytes())
.then_some(text.as_bytes())
.unwrap_or_default()
},
|_node: Node<'_>| {