-
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
Bounds parsing refactoring 2 #39158
Bounds parsing refactoring 2 #39158
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Why disallow trailing |
@durka (I'd personally keep it though, because 1) uniformity (other trailing separators are allowed), 2) it was accepted since 1.0 until now, 3) it's "naturally" allowed and you have to add extra code to the parser to prohibit it) |
@durka |
Yeah, those three reasons make sense to me. This should be cratered then,
WRT #2.
…On Wed, Jan 18, 2017 at 1:29 PM, Vadim Petrochenkov < ***@***.***> wrote:
@durka <https://github.com/durka>
No ambiguity, it's a lang team decision
<#37511 (comment)>.
(I'd personally keep it though, because 1) uniformity (other trailing
separators are allowed), 2) it was accepted since 1.0 until now, 3) it's
"naturally" allowed and you have to add extra code to the parser to
prohibit it)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39158 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n5mUeuO3uFj1On8BN5wcj7OzoCK4ks5rTlnsgaJpZM4LnJLp>
.
|
I don't think it's useful in macros, because you can just do `$($bounds)++`
and it's no problem. I was thinking of consistency between various types of
separators. But then again you don't want "1 + 1 +" to be a valid
arithmetic expression.
…On Wed, Jan 18, 2017 at 1:31 PM, Vadim Petrochenkov < ***@***.***> wrote:
@durka <https://github.com/durka>
Do you have an example of trailing + being useful in macros?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39158 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n9kaqguUTZiZyDI3GUOpgy_ahvJiks5rTlqHgaJpZM4LnJLp>
.
|
Expression |
@petrochenkov I feel like I would keep it too -- which is probably why it's parsed in the first place. I wonder if it's worth revisiting this. I found your three points convincing, and I'm not sure that we focus on the backwards compatibility point in the meeting. cc @rust-lang/lang -- we had previously decided to not accept |
I think when we agreed on that we thought we were talking about expanding what is accepted to include trailing |
@nikomatsakis If we accept this today, we should continue doing so, and document it for potential use by macros. Not worth breaking backward compatibility over. |
@nikomatsakis I agree with your reasoning; let's keep it. |
@petrochenkov care to update the PR to accept trailing @nrc you were the main one who objected, I think, so I'd like to get your input in particular (Does anyone feel we need to use rfcbot here?) |
@nikomatsakis yeah, I agree its not worth breaking for. |
Updated with trailing |
@bors r+ Thanks @petrochenkov ! |
📌 Commit 65aeafa has been approved by |
@bors r- |
Oops :) had one thing I wanted to ask |
} | ||
} | ||
for predicate in &g.where_clause.predicates { | ||
if let WherePredicate::EqPredicate(ref predicate) = *predicate { |
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.
heh, we should really remove this variant from the compiler (and parser)
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.
to be clear, not as part of this PR =)
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.
There are no plans to implement this?
Then #20041 should be officially closed or something before removing WherePredicate::EqPredicate
.
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.
Well, eventually perhaps, but at the moment there are some theoretical limitations that I do not yet know how to overcome. I would say "we may implement it eventually, but in that case we can add that stuff back in to the compiler".
// BORROWED POINTER | ||
self.expect_and()?; | ||
self.parse_borrowed_pointee()? | ||
} else if self.check_keyword(keywords::For) { | ||
// FIXME plus priority |
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.
Can you clarify what this FIXME means? Ideally, if there's an actual bug we care about here, we'd open an issue describing what is going on. Otherwise, maybe just leave it out. =)
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.
+
still has high priority in some cases.
The first case is when trait object type starts with for
:
trait Tr<'a> {}
fn f(arg: &for<'a> Tr<'a> + Send){} // Parsed as &(for<'a> Tr<'a> + Send)
I'm going to fix this in upcoming PR so I didn't create an issue.
The second case is impl Trait1 + Trait2
and it seems to be known.
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.
Updated with better comments for FIXMEs.
@bors r+ |
📌 Commit bd4d5ec has been approved by |
⌛ Testing commit bd4d5ec with merge d68ec42... |
💔 Test failed - status-travis |
@bors: retry
* android emulator wedged? Haven't seen that before...
…On Thu, Jan 26, 2017 at 3:26 PM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/195685787>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#39158 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95Aq3XBj-ktJQQjbFe66c8DYzA6Y0ks5rWSuigaJpZM4LnJLp>
.
|
⌛ Testing commit bd4d5ec with merge 989cc5d... |
@bors: retry
|
Bounds parsing refactoring 2 See #37511 for previous discussion. cc @matklad Relaxed parsing rules: - zero bounds after `:` are allowed in all contexts. - zero predicates are allowed after `where`. - trailing separator `,` is allowed after predicates in `where` clauses not followed by `{`. Other parsing rules: - trailing separator `+` is still allowed in all bound lists. Code is also cleaned up and tests added. I haven't touched parsing of trait object types yet, I'll do it later.
☀️ Test successful - status-appveyor, status-travis |
💥 Test timed out |
See #37511 for previous discussion.
cc @matklad
Relaxed parsing rules:
:
are allowed in all contexts.where
.,
is allowed after predicates inwhere
clauses not followed by{
.Other parsing rules:
+
is still allowed in all bound lists.Code is also cleaned up and tests added.
I haven't touched parsing of trait object types yet, I'll do it later.