Skip to content

Commit

Permalink
Permit impl item to end with semicolon (#118)
Browse files Browse the repository at this point in the history
* Add test with semicolons after an impl signature

* Permit impl item to end with semicolon

* Regenerate parser
  • Loading branch information
dtolnay authored Dec 6, 2021
1 parent cc7bdd3 commit 0c250fc
Show file tree
Hide file tree
Showing 5 changed files with 70,777 additions and 67,984 deletions.
25 changes: 25 additions & 0 deletions corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,31 @@ unsafe impl Foo {

(source_file (impl_item (type_identifier) (declaration_list)))

===========================================
Trait impl signature
===========================================

impl<K: Debug + Ord> Debug for OccupiedError<K>;
impl<K: Debug + Ord> Display for OccupiedError<K>;

---

(source_file
(impl_item
(type_parameters
(constrained_type_parameter
(type_identifier)
(trait_bounds (type_identifier) (type_identifier))))
(type_identifier)
(generic_type (type_identifier) (type_arguments (type_identifier))))
(impl_item
(type_parameters
(constrained_type_parameter
(type_identifier)
(trait_bounds (type_identifier) (type_identifier))))
(type_identifier)
(generic_type (type_identifier) (type_arguments (type_identifier)))))

===========================================
Impls with default functions
===========================================
Expand Down
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ module.exports = grammar({
)),
field('type', $._type),
optional($.where_clause),
field('body', $.declaration_list)
choice(field('body', $.declaration_list), ';')
),

trait_item: $ => seq(
Expand Down
21 changes: 15 additions & 6 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2602,12 +2602,21 @@
]
},
{
"type": "FIELD",
"name": "body",
"content": {
"type": "SYMBOL",
"name": "declaration_list"
}
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "body",
"content": {
"type": "SYMBOL",
"name": "declaration_list"
}
},
{
"type": "STRING",
"value": ";"
}
]
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@
"fields": {
"body": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "declaration_list",
Expand Down
Loading

0 comments on commit 0c250fc

Please sign in to comment.