Skip to content
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

Accept .. in incorrect position to avoid further errors #51201

Merged
merged 3 commits into from
Jun 6, 2018

Conversation

estebank
Copy link
Contributor

We currently give a specific message when encountering a .. anywhere
other than the end of a pattern. Modify the parser to accept it (while
still emitting the error) so that we don't also trigger "missing fields
in pattern" errors afterwards.

Add suggestions to either remove trailing , or moving the .. to the
end.

Follow up to #49268.

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 30, 2018
@rust-highfive

This comment has been minimized.

/// Parse the fields of a struct-like pattern
#[allow(unused_assignments)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be avoidable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from a false positive in a previous iteration of the code.

});
ate_comma = self.eat(&token::Comma);
Copy link
Contributor

@petrochenkov petrochenkov May 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually after rewrites like this accidental mistakes happen and parser suddenly starts silently accept double commas or something like this, but I'd never notice it in a diff like this, so let's hope our test suite is good enough!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a cursory test and the behavior when encountering multiple commas hasn't changed, the parser fails and no attempt at recovery is made.

@petrochenkov
Copy link
Contributor

r=me after fixing tidy

@estebank estebank force-pushed the dotdot branch 2 times, most recently from 8254f5f to 2bdbc77 Compare May 30, 2018 16:38
@rust-highfive

This comment has been minimized.

@estebank
Copy link
Contributor Author

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented May 30, 2018

📌 Commit 78d82df has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2018
@rust-highfive

This comment has been minimized.

We currently give a specific message when encountering a `..` anywhere
other than the end of a pattern. Modify the parser to accept it (while
still emitting the error) so that we don't also trigger "missing fields
in pattern" errors afterwards.
When using `..` somewhere other than the end, parse the rest of the
pattern correctly while still emitting an error.

Add suggestions to either remove trailing `,` or moving the `..` to the
end.
@estebank
Copy link
Contributor Author

estebank commented Jun 5, 2018

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented Jun 5, 2018

📌 Commit d66d35b has been approved by petrochenkov

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 5, 2018
Accept `..` in incorrect position to avoid further errors

We currently give a specific message when encountering a `..` anywhere
other than the end of a pattern. Modify the parser to accept it (while
still emitting the error) so that we don't also trigger "missing fields
in pattern" errors afterwards.

Add suggestions to either remove trailing `,` or moving the `..` to the
end.

Follow up to rust-lang#49268.
@bors
Copy link
Contributor

bors commented Jun 6, 2018

⌛ Testing commit d66d35b with merge eed6924b27375b8a6a2ee6c7454840e9a3a8aeb5...

@bors
Copy link
Contributor

bors commented Jun 6, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 6, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member

@bors retry -- network error

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2018
@bors
Copy link
Contributor

bors commented Jun 6, 2018

⌛ Testing commit d66d35b with merge 35aeecb...

bors added a commit that referenced this pull request Jun 6, 2018
Accept `..` in incorrect position to avoid further errors

We currently give a specific message when encountering a `..` anywhere
other than the end of a pattern. Modify the parser to accept it (while
still emitting the error) so that we don't also trigger "missing fields
in pattern" errors afterwards.

Add suggestions to either remove trailing `,` or moving the `..` to the
end.

Follow up to #49268.
@bors
Copy link
Contributor

bors commented Jun 6, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing 35aeecb to master...

@bors bors merged commit d66d35b into rust-lang:master Jun 6, 2018
@estebank estebank deleted the dotdot branch November 9, 2023 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants