-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
don't suggest erroneous trailing comma after ..
#81103
Conversation
In rust-lang#76612, suggestions were added for missing fields in patterns. However, the suggestions are being inserted just at the end of the last field in the pattern—before any trailing comma after the last field. This resulted in the "if you don't care about missing fields" suggestion to recommend code with a trailing comma after the field ellipsis (`..,`), which is actually not legal ("`..` must be at the end and cannot have a trailing comma")! Incidentally, the doc-comment on `error_unmentioned_fields` was using `you_cant_use_this_field` as an example field name (presumably copy-paste inherited from the description of Issue rust-lang#76077), but the present author found this confusing, because unmentioned fields aren't necessarily unusable. The suggested code in the diff this commit introduces to `destructuring-assignment/struct_destructure_fail.stderr` doesn't work, but it didn't work beforehand, either (because of the "found reserved identifier `_`" thing), so you can't really call it a regression; it could be fixed in a separate PR. Resolves rust-lang#78511.
@bors r+ |
📌 Commit 14eb94f has been approved by |
LL | Struct { a, b _ } = Struct { a: 1, b: 2 }; | ||
| ^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unapplicable suggestion now :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From @zackmdavis's description:
The suggested code in the diff this commit introduces to destructuring-assignment/struct_destructure_fail.stderr doesn't work, but it didn't work beforehand, either (because of the "found reserved identifier _" thing), so you can't really call it a regression; it could be fixed in a separate PR.
That seemed reasonable to me, I figured that this could be solved in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! That's what I get for skip-reading.
@bors r- to try and address the small regression I noticed. |
@bors r=davidtwco |
📌 Commit 14eb94f has been approved by |
don't suggest erroneous trailing comma after `..` In rust-lang#76612, suggestions were added for missing fields in patterns. However, the suggestions are being inserted just at the end of the last field in the pattern—before any trailing comma after the last field. This resulted in the "if you don't care about missing fields" suggestion to recommend code with a trailing comma after the field ellipsis (`..,`), which is actually not legal ("`..` must be at the end and cannot have a trailing comma")! Incidentally, the doc-comment on `error_unmentioned_fields` was using `you_cant_use_this_field` as an example field name (presumably copy-paste inherited from the description of Issue rust-lang#76077), but the present author found this confusing, because unmentioned fields aren't necessarily unusable. The suggested code in the diff this commit introduces to `destructuring-assignment/struct_destructure_fail.stderr` doesn't work, but it didn't work beforehand, either (because of the "found reserved identifier `_`" thing), so you can't really call it a regression; it could be fixed in a separate PR. Resolves rust-lang#78511. r? `@davidtwco` or `@estebank`
☀️ Test successful - checks-actions |
Account for parser recovered struct and tuple patterns to avoid invalid suggestion. Follow up to rust-lang#81103.
…etrochenkov Tweak suggestion for missing field in patterns Account for parser recovered struct and tuple patterns to avoid invalid suggestion. Follow up to rust-lang#81103.
Account for parser recovered struct and tuple patterns to avoid invalid suggestion. Follow up to rust-lang#81103.
In #76612, suggestions were added for missing fields in patterns. However, the suggestions are being inserted just at the end
of the last field in the pattern—before any trailing comma after the last field. This resulted in the "if you don't care about missing fields" suggestion to recommend code with a trailing comma after the field ellipsis (
..,
), which is actually not legal ("..
must be at the end and cannot have a trailing comma")!Incidentally, the doc-comment on
error_unmentioned_fields
was usingyou_cant_use_this_field
as an example field name (presumably copy-paste inherited from the description of Issue #76077), but the present author found this confusing, because unmentioned fields aren't necessarily unusable.The suggested code in the diff this commit introduces to
destructuring-assignment/struct_destructure_fail.stderr
doesn't work, but it didn't work beforehand, either (because of the "found reserved identifier_
" thing), so you can't really call it a regression; it could be fixed in a separate PR.Resolves #78511.
r? @davidtwco or @estebank