Uh oh!
There was an error while loading. Please reload this page.
Issue #50974 : Suboptimal error in case of duplicate , in struct constructor - #51184
Conversation
rust-highfive
commented
May 29, 2018
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
| } else { | ||
| err.span_label(self.span, "expected identifier"); | ||
| if self.token == token::Comma { | ||
| err.span_suggestion(self.span, "remove this comma", ",".into()); |
There was a problem hiding this comment.
The third argument here should be an empty string. This will change the output to help: remove this comma.
| err.span_label(self.span, format!("expected identifier, found {}", token_descr)); | ||
| } else { | ||
| err.span_label(self.span, "expected identifier"); | ||
| if self.token == token::Comma { |
There was a problem hiding this comment.
I'm not sure this is the best thing to do, as is. I would only add this suggestion if the next token is indeed an ident:
if self.token == token::Comma && self.look_ahead(1, |t| *t.is_ident()) {
There was a problem hiding this comment.
I think it will still be useful even if the next token is not an identifier. We should not ever have 2 commas in a row in a struct constructor.
structBar{a:u8,b:u8}let foo = Bar{a:42,b:42,,};In this example, the user still has to remove the duplicate comma to get his code to compile.
| self.recover_stmt(); | ||
| break; | ||
| if self.token != token::Comma { |
There was a problem hiding this comment.
This confuses me a bit — when does this , token get dropped, if not by recover_stmt?
There was a problem hiding this comment.
It gets dropped afterwards at line 2541 :
self.expect_one_of(&[token::Comma],&[token::CloseDelim(token::Brace)])Should I add a comment to clarify this?
There was a problem hiding this comment.
Ah, I see now. Yes, put a comment if you don't mind.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented
May 31, 2018
@lambtowolf think you can add that explanatory comment? =) |
nikomatsakis
commented
Jun 5, 2018
@bors r+ |
bors
commented
Jun 5, 2018
📌 Commit 01559fb has been approved by |
Issue rust-lang#50974 : Suboptimal error in case of duplicate `,` in struct constructor Fixesrust-lang#50974
bors
commented
Jun 6, 2018
🔒 Merge conflict |
nikomatsakis
commented
Jun 6, 2018
@lambtowolf Needs rebase 😿 |
emilyalbini
commented
Jun 8, 2018
@lambtowolf you should rebase on master, even if you don't see any conflict at first glance. |
emilyalbini
commented
Jun 18, 2018
Ping from triage @lambtowolf! It's been a while since we heard from you, will you have time to work on this again? |
bors
commented
Jun 21, 2018
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message |
1 similar comment
bors
commented
Jun 22, 2018
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message |
Only display the "remove this comma" suggestion when followed by an identifier
emilyalbini
commented
Jun 22, 2018
Rebased this on top of the latest master. @bors r=nikomatsakis |
bors
commented
Jun 22, 2018
📌 Commit a99767f has been approved by |
bors
commented
Jun 22, 2018
bors
commented
Jun 22, 2018
☀️ Test successful - status-appveyor, status-travis |
Fixes#50974