tree-sitter-rust
tree-sitter-rust copied to clipboard
Parse error in syntactically-valid program
Code extracted from rustc souce code:
fn hash_body(
item_like: impl for<'a> HashStable<StableHashingContext<'a>>,
hir_body_nodes: &mut Vec<(DefPathHash, Fingerprint)>,
) -> Fingerprint {
let hash = hash(hcx, HirItemLike { item_like: &item_like });
}
fn upstream_crates() {
let mut upstream_crates: Vec<_> = cstore;
}
This program is syntactically valid, but using the master branch of tree-sitter-rust currently this can't be parsed. Current AST:
(ERROR [0, 0] - [10, 0]
(identifier [0, 3] - [0, 12])
(identifier [1, 4] - [1, 13])
(for_lifetimes [1, 20] - [1, 27]
(lifetime [1, 24] - [1, 26]
(identifier [1, 25] - [1, 26])))
(ERROR [1, 28] - [4, 14]
(generic_type [1, 28] - [1, 64]
type: (type_identifier [1, 28] - [1, 38])
type_arguments: (type_arguments [1, 38] - [1, 64]
(generic_type [1, 39] - [1, 63]
type: (type_identifier [1, 39] - [1, 59])
type_arguments: (type_arguments [1, 59] - [1, 63]
(lifetime [1, 60] - [1, 62]
(identifier [1, 61] - [1, 62]))))))
(identifier [2, 4] - [2, 18])
(mutable_specifier [2, 21] - [2, 24])
(generic_type [2, 25] - [2, 56]
type: (type_identifier [2, 25] - [2, 28])
type_arguments: (type_arguments [2, 28] - [2, 56]
(tuple_type [2, 29] - [2, 55]
(type_identifier [2, 30] - [2, 41])
(type_identifier [2, 43] - [2, 54]))))
(identifier [3, 5] - [3, 16])
(identifier [4, 8] - [4, 12]))
(identifier [4, 15] - [4, 19])
(type_identifier [4, 20] - [4, 23])
(ERROR [4, 25] - [7, 2]
(struct_pattern [4, 25] - [4, 62]
type: (type_identifier [4, 25] - [4, 36])
(field_pattern [4, 39] - [4, 60]
name: (field_identifier [4, 39] - [4, 48])
pattern: (reference_pattern [4, 50] - [4, 60]
(identifier [4, 51] - [4, 60])))))
(identifier [7, 3] - [7, 18])
(ERROR [7, 18] - [7, 20]
(parameters [7, 18] - [7, 20]))
(ERROR [8, 4] - [8, 7]
(identifier [8, 4] - [8, 7]))
(mutable_specifier [8, 8] - [8, 11])
(identifier [8, 12] - [8, 27])
(generic_type [8, 29] - [8, 35]
type: (type_identifier [8, 29] - [8, 32])
type_arguments: (type_arguments [8, 32] - [8, 35]
(type_identifier [8, 33] - [8, 34])))
(identifier [8, 38] - [8, 44]))
It seems like the problem is the type impl for<'a> HashStable<StableHashingContext<'a>>.