Skip to content

syntax: + has incorrect priority in trait object types starting with for #39317

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
petrochenkov opened this issue Jan 26, 2017 · 0 comments · Fixed by #40043
Closed

syntax: + has incorrect priority in trait object types starting with for #39317

petrochenkov opened this issue Jan 26, 2017 · 0 comments · Fixed by #40043
Assignees
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST

Comments

@petrochenkov
Copy link
Contributor

&for<'a> Tr<'a> + Send is parsed as &(for<'a> Tr<'a> + Send) while RFC 438 tells that it should be parsed as (&for<'a> Tr<'a>) + Send and therefore be invalid.

Another example: Fn() -> for<'a> Tr<'a> + Send is parsed as Fn() -> (for<'a> Tr<'a> + Send) instead of (Fn() -> for<'a> Tr<'a>) + Send.

cc #39158 (comment)

@petrochenkov petrochenkov added the A-parser Area: The lexing & parsing of Rust source code to an AST label Feb 19, 2017
@petrochenkov petrochenkov self-assigned this Feb 19, 2017
bors added a commit that referenced this issue Mar 22, 2017
Refactor parsing of trait object types

Bugs are fixed and code is cleaned up.

User visible changes:
- `ty` matcher in macros accepts trait object types like `Write + Send` (#39080)
- Buggy priority of `+` in trait object types starting with `for` is fixed (#39317). `&for<'a> Trait<'a> + Send` is now parsed as `(&for<'a> Trait<'a>) + Send` and requires parens `&(for<'a> Trait<'a> + Send)`. For comparison, `&Send + for<'a> Trait<'a>` was parsed like this since [Nov 27, 2014](#19298).
- Trailing `+`s are supported in trait objects, like in other bounds.
- Better error reporting for trait objects starting with `?Sized`.

Fixes #39080
Fixes #39317 [breaking-change]
Closes #39298
cc #39085 (fixed, then reverted #40043 (comment))
cc #39318 (fixed, then reverted #40043 (comment))

r? @nikomatsakis
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant