Skip to content

Commit 53d6f06

Browse files
committed
Fix the grammar of const param defaults by reusing rule for const args
`struct T<const N: U = crate>;` is syntactically valid but the previous definition of rule *ConstParam* didn't capture that fact since it listed *IDENTIFIER* while it needed to be *SimplePathSegment*.
1 parent ac7b991 commit 53d6f06

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/items/generics.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ LifetimeParam -> Lifetime ( `:` LifetimeBounds )?
1111
1212
TypeParam -> IDENTIFIER ( `:` Bounds? )? ( `=` Type )?
1313
14-
ConstParam ->
15-
`const` IDENTIFIER `:` Type
16-
( `=` ( BlockExpression | IDENTIFIER | `-`?LiteralExpression ) )?
14+
ConstParam -> `const` IDENTIFIER `:` Type ( `=` ConstArg )?
1715
```
1816

1917
r[items.generics.syntax.intro]

src/paths.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ TypeList ->
6262
( Type `,` )* Type `,`?
6363
6464
GenericArg ->
65-
Lifetime | Type | GenericArgsConst | GenericArgsBinding | GenericArgsBounds
65+
Lifetime | Type | ConstArg | GenericArgsBinding | GenericArgsBounds
6666
67-
GenericArgsConst ->
67+
ConstArg ->
6868
BlockExpression
69-
| LiteralExpression
70-
| `-` LiteralExpression
69+
| `-`? LiteralExpression
7170
| SimplePathSegment
7271
7372
GenericArgsBinding ->

0 commit comments

Comments
 (0)