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

syntax: Rewrite parsing of patterns #23930

Merged
merged 2 commits into from
Apr 3, 2015
Merged

Conversation

petrochenkov
Copy link
Contributor

Fixes #22757
Fixes #22972
Fixes #23044
Fixes #23151
Fixes #23597
Fixes #23656
Fixes #23929
It also fixes some other corner cases in range patterns, like incorrect spans or not accepting global paths after ....

It passes make check but needs some additional tests (then it will fix #22546 as well), I'll write them today or tomorrow.

@rust-highfive
Copy link
Collaborator

r? @nrc

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

@alexcrichton
Copy link
Member

Nice!

if self.token == token::BinOp(token::Or) &&
self.restrictions.contains(RESTRICTION_NO_BAR_OP) {
return lhs;
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain the reasoning behind why it is safe to remove this check please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flag RESTRICTION_NO_BAR_OP is checked here but it isn't set anywhere, so I removed the check and the flag itself. RESTRICTION_NO_BAR_OP was used before in parse_pat, see my line comments there.

@nrc
Copy link
Member

nrc commented Apr 2, 2015

lgtm, I just want to be clear about removing that one check

self.look_ahead(2, |t| {
*t != token::Comma && *t != token::CloseDelim(token::Bracket)
}) {
let start = self.parse_expr_res(RESTRICTION_NO_BAR_OP);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here parse_expr_res(RESTRICTION_NO_BAR_OP) was mistakenly used to parse plain identifier.

@nrc
Copy link
Member

nrc commented Apr 2, 2015

Ok, sounds good, thanks for the explanation.

@bors: r+ d9a0ca01f3938efbb34587e3f52214d8c0bc1624

@bors
Copy link
Contributor

bors commented Apr 2, 2015

⌛ Testing commit d9a0ca0 with merge eb9ca18...

@bors
Copy link
Contributor

bors commented Apr 2, 2015

💔 Test failed - auto-linux-64-x-android-t

@petrochenkov
Copy link
Contributor Author

Rebased and fixed.

@nrc
Copy link
Member

nrc commented Apr 3, 2015

@bors: r+ 76567a6

@bors
Copy link
Contributor

bors commented Apr 3, 2015

⌛ Testing commit 76567a6 with merge 0640106...

@bors
Copy link
Contributor

bors commented Apr 3, 2015

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented Apr 3, 2015

⌛ Testing commit 76567a6 with merge 80def6c...

bors added a commit that referenced this pull request Apr 3, 2015
Fixes #22757
Fixes #22972
Fixes #23044
Fixes #23151
Fixes #23597
Fixes #23656
Fixes #23929
It also fixes some other corner cases in range patterns, like incorrect spans or not accepting global paths after `...`.

It passes `make check` but needs some additional tests (then it will fix #22546 as well), I'll write them today or tomorrow.
Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 3, 2015
Fixes rust-lang#22757
Fixes rust-lang#22972
Fixes rust-lang#23044
Fixes rust-lang#23151
Fixes rust-lang#23597
Fixes rust-lang#23656
Fixes rust-lang#23929
It also fixes some other corner cases in range patterns, like incorrect spans or not accepting global paths after `...`.

It passes `make check` but needs some additional tests (then it will fix rust-lang#22546 as well), I'll write them today or tomorrow.
bors added a commit that referenced this pull request Apr 3, 2015
@bors bors merged commit 76567a6 into rust-lang:master Apr 3, 2015
@ghost
Copy link

ghost commented Apr 3, 2015

@petrochenkov Did you mean to say that you'd add the test cases in a separate PR? As it is, none of the fixed issues have any related tests so perhaps we should reopen them?

@petrochenkov
Copy link
Contributor Author

@jakub-
I meant to write the tests as a part of this PR but was busy, so I'm going to submit them separately. All the mentioned issues are essentially duplicates, so I'll open one blanket E-needstest issue for them if I don't submit the PR with tests in the next couple of hours.

Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 4, 2015
@bombless
Copy link
Contributor

bombless commented Apr 4, 2015

Hmm @bors closed #22546 after merging this, but I believe it is an irrelevant issue, since the core idea of that issue is about discussing whether we should allow type parameters in pattern.

@bombless
Copy link
Contributor

bombless commented Apr 4, 2015

cc @pnkfelix

@brson
Copy link
Contributor

brson commented Apr 7, 2015

@bombless I reopened that issue for you.

@brson
Copy link
Contributor

brson commented Apr 7, 2015

Awesome list of fixes.

@pnkfelix
Copy link
Member

pnkfelix commented Apr 7, 2015

@bombless thanks for the pro-active note. However, during triage (I think), the team decided as noted in e.g. this comment that we would keep the syntax, and that we just needed to exercise the edge cases more thoroughly.

@pnkfelix
Copy link
Member

pnkfelix commented Apr 7, 2015

But, skimming this PR, it seems like it did not actually add any tests relevant to #22546, so I guess that issue should remain open.

@petrochenkov
Copy link
Contributor Author

@pnkfelix
The follow-up PR (#24033) contains some tests for #22546. I don't know, whether that enough or not.

@petrochenkov petrochenkov deleted the issue23656 branch May 9, 2015 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment