Skip to content

Commit 59130c5

Browse files
committed
add bounded_type to trait choice in abstract_type
1 parent 5edb201 commit 59130c5

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
@@ -896,14 +896,15 @@ module.exports = grammar({
896896
abstract_type: $ => seq(
897897
'impl',
898898
optional(seq('for', $.type_parameters)),
899-
field('trait', choice(
899+
field('trait', prec(1, choice(
900900
$._type_identifier,
901901
$.scoped_type_identifier,
902902
$.removed_trait_bound,
903903
$.generic_type,
904904
$.function_type,
905905
$.tuple_type,
906-
)),
906+
$.bounded_type,
907+
))),
907908
),
908909

909910
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)