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

Trailing + in bounds are allowed #41158

Closed
qnighy opened this issue Apr 8, 2017 · 5 comments
Closed

Trailing + in bounds are allowed #41158

qnighy opened this issue Apr 8, 2017 · 5 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@qnighy
Copy link
Contributor

qnighy commented Apr 8, 2017

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)
@petrochenkov
Copy link
Contributor

petrochenkov commented Apr 8, 2017

This works as expected, see #39158 for the discussion.

However, the comments on the parser suggest they shouldn't be allowed.
grammar.md also suggests they shouldn't.

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.

@petrochenkov petrochenkov added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Apr 8, 2017
@alexeyzab
Copy link
Contributor

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, the bound-list section probably?

@petrochenkov
Copy link
Contributor

@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
Copy link
Contributor

@petrochenkov Good point, my bad. Thanks for pointing that out!

alexeyzab added a commit to alexeyzab/rust that referenced this issue Apr 13, 2017
@alexeyzab
Copy link
Contributor

Adjusted the comment and made a new paragraph for the current grammar. Let me know if this is okay.

bors added a commit that referenced this issue Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants