Skip to content

Commit e86119b

Browse files
authored
parse impl types (abstract types) where the lifetime comes first (#258)
* add bounded_type to trait choice in abstract_type * simplify bounded_type * chore: tree-sitter generate
1 parent bb08b6f commit e86119b

File tree

5 files changed

+106566
-104636
lines changed

5 files changed

+106566
-104636
lines changed

grammar.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -832,13 +832,10 @@ module.exports = grammar({
832832
field('type_arguments', $.type_arguments),
833833
),
834834

835-
bounded_type: $ => prec.left(-1, choice(
836-
seq($.lifetime, '+', $._type),
837-
seq($._type, '+', $._type),
838-
seq($._type, '+', choice(
839-
$.lifetime,
840-
$.use_bounds,
841-
)),
835+
bounded_type: $ => prec.left(-1, seq(
836+
choice($.lifetime, $._type, $.use_bounds),
837+
'+',
838+
choice($.lifetime, $._type, $.use_bounds),
842839
)),
843840

844841
use_bounds: $ => seq(
@@ -896,14 +893,15 @@ module.exports = grammar({
896893
abstract_type: $ => seq(
897894
'impl',
898895
optional(seq('for', $.type_parameters)),
899-
field('trait', choice(
896+
field('trait', prec(1, choice(
900897
$._type_identifier,
901898
$.scoped_type_identifier,
902899
$.removed_trait_bound,
903900
$.generic_type,
904901
$.function_type,
905902
$.tuple_type,
906-
)),
903+
$.bounded_type,
904+
))),
907905
),
908906

909907
dynamic_type: $ => seq(

src/grammar.json

+48-62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)