Better error message for ..
in struct patterns not in last position
#49257
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Since the
let P(.., y) = p;
syntax is allowed in unnamed patterns, people will try the same in named patterns,let P { .., y } = p;
,and it won't work. Right now the error isfollowed by other errors about "pattern does not mention field x". Test code playground link
Adding a clear error message should be pretty easy, just check if there is a comma after
DotDot
and display a better error message "..
must always be the last field, and it cannot have a trailing comma". Actually, I think this is the code that checks if..
is followed by a}
, so adding the,
check should be pretty straight-forward:rust/src/libsyntax/parse/parser.rs
Lines 3672 to 3677 in c19264f
The text was updated successfully, but these errors were encountered: