Suggest a comma if a struct initializer field fails to parse

Currently, we emit a "try adding a comma" suggestion if a comma is
missing in a struct definition. However, we emit no such suggestion if a
comma is missing in a struct initializer.

This commit adds a "try adding a comma" suggestion when we don't find a
comma during the parsing of a struct initializer field.

The change to `src/test/ui/parser/removed-syntax-with-1.stderr` isn't
great, but I don't see a good way of avoiding it.
This commit is contained in:
Aaron Hill 2020-02-14 22:28:13 -05:00
parent b92c6ee882
commit 98757f14d0
No known key found for this signature in database
GPG key ID: B4087E510E98B164
4 changed files with 46 additions and 3 deletions

View file

@ -2,8 +2,9 @@ error: expected one of `,`, `.`, `?`, `}`, or an operator, found `with`
--> $DIR/removed-syntax-with-1.rs:8:25
|
LL | let b = S { foo: () with a, bar: () };
| - ^^^^ expected one of `,`, `.`, `?`, `}`, or an operator
| |
| - -^^^^ expected one of `,`, `.`, `?`, `}`, or an operator
| | |
| | help: try adding a comma: `,`
| while parsing this struct
error: aborting due to previous error