Skip to content

Trailing + in bounds are allowed #41158

Closed
@qnighy

Description

@qnighy
Contributor

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)

Activity

petrochenkov

petrochenkov commented on Apr 8, 2017

@petrochenkov
Contributor

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.

added
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
on Apr 8, 2017
alexeyzab

alexeyzab commented on Apr 12, 2017

@alexeyzab
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

petrochenkov commented on Apr 12, 2017

@petrochenkov
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

alexeyzab commented on Apr 12, 2017

@alexeyzab
Contributor

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

added a commit that references this issue on Apr 13, 2017
a507370
alexeyzab

alexeyzab commented on Apr 13, 2017

@alexeyzab
Contributor

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

added a commit that references this issue on Apr 17, 2017

Auto merge of #41264 - alexeyzab:41158-fix-docs, r=steveklabnik

011f240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @qnighy@alexeyzab@petrochenkov

        Issue actions

          Trailing `+` in bounds are allowed · Issue #41158 · rust-lang/rust