Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upsyntax: Trait object types permit extra parentheses on the first bound #39318
Comments
petrochenkov
added
the
regression-from-stable-to-stable
label
Feb 10, 2017
petrochenkov
self-assigned this
Feb 19, 2017
petrochenkov
added
the
A-parser
label
Feb 19, 2017
petrochenkov
referenced this issue
Feb 23, 2017
Merged
Refactor parsing of trait object types #40043
This was referenced Mar 4, 2017
brson
added
I-nominated
I-compiletime
T-compiler
and removed
I-compiletime
labels
Mar 9, 2017
This comment has been minimized.
This comment has been minimized.
|
Needs a P-tag. Thanks for the fixes @petrochenkov |
nikomatsakis
added
T-lang
and removed
I-nominated
labels
Mar 16, 2017
This comment has been minimized.
This comment has been minimized.
|
I'm removing Nominated -- it's not clear that we want to actually enforce this rule. See the discussion on #40043 |
bors
added a commit
that referenced
this issue
Mar 22, 2017
brson
added
I-needs-decision
P-medium
labels
Mar 23, 2017
nikomatsakis
added
I-nominated
and removed
T-compiler
labels
Mar 23, 2017
This comment has been minimized.
This comment has been minimized.
|
Nominating for lang-team discussion: there was some back and forth on the original PR. We should figure out what is the right venue/process to finalize decision here. |
This comment has been minimized.
This comment has been minimized.
|
OK, we talked about this in @rust-lang/lang meeting. We decided that it'd be best to have the discussion stay on this issue, and we can just do a "rfcbot" final decision here when needed. I think there was also some agreement @petrochenkov that it makes sense to support Nonetheless there was some reluctance to break code that is using parentheses. It's not entirely clear why that should be required. So one question that @pnkfelix wanted to clarify was: Can you elaborate on why you would not want to permit
Is it simply that there are no other operators in where-clauses, and hence supporting parentheses is sort of unnecessary? (Put another way, the idea of allowing all bounds to accepts parens is appealing and seems natural enough.) |
nikomatsakis
removed
the
I-nominated
label
Mar 24, 2017
This comment has been minimized.
This comment has been minimized.
Ok, I'll try to elaborate. |
This comment has been minimized.
This comment has been minimized.
|
I. The parens are only for backward compatibility and not useful enough on their own. Assume for a minute that the 1.6 regression never happened, the parens are not accepted, and I'm submitting a new RFC proposing to add parentheses to the bounds grammar. The best solution from this position is what I did in #40043 originally - continue parsing the parens around the first bound, as they are parsed now, but issue a warning. The warning can be turned into a hard error eventually, maybe in half a year, maybe later, it's not especially important. |
This comment has been minimized.
This comment has been minimized.
|
II. The parens are legitimately useful. It may be reasonable to visually emphasize that Nicer grouping is still not a very strong motivation, so even if we add it, we should not sacrifice other important properties. Now let's explore some possible syntax additions.
|
This comment has been minimized.
This comment has been minimized.
|
Ok, now I spent more than an hour of time fleshing out the details of this completely worthless feature. |
This comment has been minimized.
This comment has been minimized.
|
Until I read #39318 (comment) , I agreed with the first position: only useful for backward compatibility. However, I find your example of Based on that comment, in the absence of some hard conflict with another grammar feature, I'd be tempted to say "keep parentheses, and don't deprecate them". I'd even be inclined to say that the style guide should recommend them around |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov I agree we shouldn't spend too much time on this; I don't even want to spend the time to track a deprecation. That's why I want to just accept parens in bounds and be done with it. There are a number of quirks that we accept for backwards compatibility reasons (especially in bounds syntax, such as trailing |
This comment has been minimized.
This comment has been minimized.
|
Seems like lang team has an idea what to do here. Let's try to resolve quickly one way or the other. |
petrochenkov
referenced this issue
Apr 4, 2017
Merged
syntax: Support parentheses around trait bounds #41077
This comment has been minimized.
This comment has been minimized.
Deprecation is certainly easier (add couple of lines of code + test, then remove them) and affects only rustc. |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov A parsing impl needs to support it and the reference needs to mention it, but paren grouping of operations is not a very foreign concept to most users (if it is they'll have to learn it anyway for other uses) & we don't ever recommend using it. I really don't see these as significant costs. Deprecation of course does not only impact rustc but it also impacts any users who were using parens in their trait objects. Do we have crater results on that? Its also plausible that we will create bound operators someday other than I don't feel strongly about this and it seems like you do, so a part of me is inclined to just say we should do whatever. |
This comment has been minimized.
This comment has been minimized.
#40043 (comment) - three regressions, all are fixed upstream. |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov it feels funny to me to support parens but not |
This comment has been minimized.
This comment has been minimized.
|
As for your other examples:
I would reject this for now, but I could see eventually that it might be useful to be able to share the quantifier over multiple bounds (e.g., |
This comment has been minimized.
This comment has been minimized.
Every syntactic addition in this area adds more ambiguities and I'd want to avoid them unless really necessary. |
This comment has been minimized.
This comment has been minimized.
|
I think I'd really prefer to agree to a particular grammar here. It seems surprising to me to allow some forms of bounds to be parenthesized but not others -- e.g. I also don't have a problem with |
This comment has been minimized.
This comment has been minimized.
Disambiguation code just continues piling up when you add |
petrochenkov commentedJan 26, 2017
•
edited
The syntax for object types is the same as for other bounds -
Bound + Bound + Bound + ....and parentheses are not a part of bound syntax.This is a stable-stable regression, introduced in Rust 1.6 by #29870.
cc #39169 #39179
Current status
(Bound) + Bound + ....is still parsed, but with a warning. This is a "hardcoded" warning and not a lint, lints cannot be reported from.libsyntax