tree-sitter-rust
tree-sitter-rust copied to clipboard
bug: impl trait bound starting with a lifetime misparsed
Did you check existing issues?
- [X] I have read all the tree-sitter docs if it relates to using the parser
- [X] I have searched the existing issues of tree-sitter-rust
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version
)
No response
Describe the bug
impl trait claused that start with a lifetime are misparsed and produce an error token. The corresponding where clauses are parsed just fine
Steps To Reproduce/Bad Parse Tree
Try to parse the following code :
fn foo<'a>(x: impl 'a + Clone ) {}
You obtain the following parse-tree :
source_file [0, 0] - [1, 0]
function_item [0, 0] - [0, 33]
name: identifier [0, 3] - [0, 6]
type_parameters: type_parameters [0, 6] - [0, 10]
lifetime [0, 7] - [0, 9]
identifier [0, 8] - [0, 9]
parameters: parameters [0, 10] - [0, 30]
parameter [0, 11] - [0, 29]
pattern: identifier [0, 11] - [0, 12]
type: bounded_type [0, 14] - [0, 29]
abstract_type [0, 14] - [0, 21]
ERROR [0, 19] - [0, 20]
trait: type_identifier [0, 20] - [0, 21]
type_identifier [0, 24] - [0, 29]
body: block [0, 31] - [0, 33]
Expected Behavior/Parse Tree
Not sure what exact parse tree should be produced. It seems to me that the rule for abstract_type
is wrong as it seems to support only one type.