Skip to content

Commit d48d2c9

Browse files
committed
add bounded_type to trait choice in abstract_type
1 parent 6e883a2 commit d48d2c9

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

grammar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,14 +893,15 @@ module.exports = grammar({
893893
abstract_type: $ => seq(
894894
'impl',
895895
optional(seq('for', $.type_parameters)),
896-
field('trait', choice(
896+
field('trait', prec(1, choice(
897897
$._type_identifier,
898898
$.scoped_type_identifier,
899899
$.removed_trait_bound,
900900
$.generic_type,
901901
$.function_type,
902902
$.tuple_type,
903-
)),
903+
$.bounded_type,
904+
))),
904905
),
905906

906907
dynamic_type: $ => seq(

test/corpus/declarations.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,31 @@ fn triples(a: impl B) -> impl Iterator<Item=(usize)> {
266266
(primitive_type))))))
267267
(block)))
268268

269+
================================================================================
270+
Impl with lifetimes first
271+
================================================================================
272+
273+
fn foo<'a>(x: impl 'a + Clone) {}
274+
275+
--------------------------------------------------------------------------------
276+
277+
(source_file
278+
(function_item
279+
(identifier)
280+
(type_parameters
281+
(lifetime_parameter
282+
(lifetime
283+
(identifier))))
284+
(parameters
285+
(parameter
286+
(identifier)
287+
(abstract_type
288+
(bounded_type
289+
(lifetime
290+
(identifier))
291+
(type_identifier)))))
292+
(block)))
293+
269294
================================================================================
270295
Functions with precise capture syntax
271296
================================================================================

0 commit comments

Comments
 (0)