Skip to content

Commit 0ee2624

Browse files
committed
feat: allow attribute items in type parameters
1 parent b3be181 commit 0ee2624

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

grammar.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,16 @@ module.exports = grammar({
542542

543543
type_parameters: $ => prec(1, seq(
544544
'<',
545-
sepBy1(',', choice(
546-
$.lifetime,
547-
$.metavariable,
548-
$._type_identifier,
549-
$.constrained_type_parameter,
550-
$.optional_type_parameter,
551-
$.const_parameter,
545+
sepBy1(',', seq(
546+
repeat($.attribute_item),
547+
choice(
548+
$.lifetime,
549+
$.metavariable,
550+
$._type_identifier,
551+
$.constrained_type_parameter,
552+
$.optional_type_parameter,
553+
$.const_parameter,
554+
),
552555
)),
553556
optional(','),
554557
'>',

test/corpus/declarations.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ struct A<B> {}
667667
struct C<'a, 'b> {}
668668
struct C<'a,> {}
669669
struct D<const SIZE: usize> {}
670+
struct E<#[attr] T> {}
670671

671672
--------------------------------------------------------------------------------
672673

@@ -696,6 +697,14 @@ struct D<const SIZE: usize> {}
696697
(const_parameter
697698
name: (identifier)
698699
type: (primitive_type)))
700+
body: (field_declaration_list))
701+
(struct_item
702+
name: (type_identifier)
703+
type_parameters: (type_parameters
704+
(attribute_item
705+
(attribute
706+
(identifier)))
707+
(type_identifier))
699708
body: (field_declaration_list)))
700709

701710
================================================================================
@@ -1668,7 +1677,7 @@ fn univariant(this: &impl ?Sized, that: &(impl LayoutCalculator + ?Sized)) {}
16681677
(block)))
16691678

16701679
================================================================================
1671-
Trait bounds in type in trait
1680+
Trait bounds in type arguments in trait
16721681
================================================================================
16731682

16741683
impl<T: AstDeref<Target: HasNodeId>> HasNodeId for T {}

0 commit comments

Comments
 (0)