Closed
Description
Current parser allows ty/lt bounds have extra +
. However, the comments on the parser suggest they shouldn't be allowed. grammar.md also suggests they shouldn't.
Expected behavior
Both the first and second lines should lead to parse error.
fn f<'a>() where 'a: 'a + {}
fn g<'a, X>() where X: 'a + {}
fn main() {
}
Current behavior
The current stable and nightly compilers allow the above code.
Meta
Tested on Rust Playground.
stable
rustc 1.16.0 (30cf806ef 2017-03-10)
nightly
rustc 1.18.0-nightly (50c186419 2017-04-06)
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
petrochenkov commentedon Apr 8, 2017
This works as expected, see #39158 for the discussion.
I forgot to update the comment :(
grammar.md also seems to be largely unmaintained.
Marking this as a documentation issue so someone could fix the comment and grammar.md.
alexeyzab commentedon Apr 12, 2017
Hi there!
I'd like to fix this. I'll remove the
without trailing '+'
part from the comment, but I am not sure which part to edit in the grammar.md. I am assuming it has to be somewhere here, thebound-list
section probably?petrochenkov commentedon Apr 12, 2017
@alexeyzab
Placing the bounds grammar into the closure grammar seems strange (https://github.com/rust-lang/rust/blob/master/src/doc/grammar.md#closure-types is also very outdated), I'd create a new separate paragraph for it.
The current grammar for bounds can be found here.
There are also two places mentioning "without trailing '+'", the second one needs to be fixed as well.
alexeyzab commentedon Apr 12, 2017
@petrochenkov Good point, my bad. Thanks for pointing that out!
Fix old docs
alexeyzab commentedon Apr 13, 2017
Adjusted the comment and made a new paragraph for the current grammar. Let me know if this is okay.
Auto merge of #41264 - alexeyzab:41158-fix-docs, r=steveklabnik