test(binding_rust): Use some redundancy to trigger more clear comliler error on the master
@@ -3046,13 +3046,16 @@ fn test_query_lifetime_is_separate_from_nodes_lifetime() {
let mut parser = Parser::new();
parser.set_language(language).unwrap();
let tree = parser.parse(&source, None).unwrap();
- let query = Query::new(language, query).unwrap();
fn take_first_node_from_captures<'tree>(
source: &str,
- query: &Query,
+ query: &str,
node: Node<'tree>,
) -> Node<'tree> {
+ // Following 2 lines are redundant but needed to demonstrate
+ // more understandable compiler error message
+ let language = get_language("javascript");
+ let query = Query::new(language, query).unwrap();
let mut cursor = QueryCursor::new();
let node = cursor
.matches(&query, node, to_callback(source))
@@ -3063,14 +3066,16 @@ fn test_query_lifetime_is_separate_from_nodes_lifetime() {
node
}
- let node = take_first_node_from_captures(source, &query, tree.root_node());
+ let node = take_first_node_from_captures(source, query, tree.root_node());
assert_eq!(node.kind(), "call_expression");
fn take_first_node_from_matches<'tree>(
source: &str,
- query: &Query,
+ query: &str,
node: Node<'tree>,
) -> Node<'tree> {
+ let language = get_language("javascript");
+ let query = Query::new(language, query).unwrap();
let mut cursor = QueryCursor::new();
let node = cursor
.captures(&query, node, to_callback(source))
@@ -3082,7 +3087,7 @@ fn test_query_lifetime_is_separate_from_nodes_lifetime() {
node
}
- let node = take_first_node_from_matches(source, &query, tree.root_node());
+ let node = take_first_node_from_matches(source, query, tree.root_node());
assert_eq!(node.kind(), "call_expression");
});
}
