Skip to content

Commit 0c250fc

Browse files
authored
Permit impl item to end with semicolon (#118)
* Add test with semicolons after an impl signature * Permit impl item to end with semicolon * Regenerate parser
1 parent cc7bdd3 commit 0c250fc

File tree

5 files changed

+70777
-67984
lines changed

5 files changed

+70777
-67984
lines changed

corpus/declarations.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,31 @@ unsafe impl Foo {
970970

971971
(source_file (impl_item (type_identifier) (declaration_list)))
972972

973+
===========================================
974+
Trait impl signature
975+
===========================================
976+
977+
impl<K: Debug + Ord> Debug for OccupiedError<K>;
978+
impl<K: Debug + Ord> Display for OccupiedError<K>;
979+
980+
---
981+
982+
(source_file
983+
(impl_item
984+
(type_parameters
985+
(constrained_type_parameter
986+
(type_identifier)
987+
(trait_bounds (type_identifier) (type_identifier))))
988+
(type_identifier)
989+
(generic_type (type_identifier) (type_arguments (type_identifier))))
990+
(impl_item
991+
(type_parameters
992+
(constrained_type_parameter
993+
(type_identifier)
994+
(trait_bounds (type_identifier) (type_identifier))))
995+
(type_identifier)
996+
(generic_type (type_identifier) (type_arguments (type_identifier)))))
997+
973998
===========================================
974999
Impls with default functions
9751000
===========================================

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ module.exports = grammar({
464464
)),
465465
field('type', $._type),
466466
optional($.where_clause),
467-
field('body', $.declaration_list)
467+
choice(field('body', $.declaration_list), ';')
468468
),
469469

470470
trait_item: $ => seq(

src/grammar.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,12 +2602,21 @@
26022602
]
26032603
},
26042604
{
2605-
"type": "FIELD",
2606-
"name": "body",
2607-
"content": {
2608-
"type": "SYMBOL",
2609-
"name": "declaration_list"
2610-
}
2605+
"type": "CHOICE",
2606+
"members": [
2607+
{
2608+
"type": "FIELD",
2609+
"name": "body",
2610+
"content": {
2611+
"type": "SYMBOL",
2612+
"name": "declaration_list"
2613+
}
2614+
},
2615+
{
2616+
"type": "STRING",
2617+
"value": ";"
2618+
}
2619+
]
26112620
}
26122621
]
26132622
},

src/node-types.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@
21132113
"fields": {
21142114
"body": {
21152115
"multiple": false,
2116-
"required": true,
2116+
"required": false,
21172117
"types": [
21182118
{
21192119
"type": "declaration_list",

0 commit comments

Comments
 (0)