Skip to content
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

&..: unexpected token .. #25119

Closed
huonw opened this issue May 5, 2015 · 3 comments
Closed

&..: unexpected token .. #25119

huonw opened this issue May 5, 2015 · 3 comments
Labels
A-grammar Area: The grammar of Rust A-parser Area: The parsing of Rust source code to an AST

Comments

@huonw
Copy link
Member

huonw commented May 5, 2015

fn main() { &..; }
<anon>:1:14: 1:16 error: unexpected token: `..`
<anon>:1 fn main() { &..; }
                      ^~

This may be on purpose, but if not, this is useful for passing .. into generic APIs that take references.

@huonw huonw added A-grammar Area: The grammar of Rust A-parser Area: The parsing of Rust source code to an AST labels May 5, 2015
@klutzy
Copy link
Contributor

klutzy commented May 5, 2015

parser-lalr accepts &..; well: (ExprAddrOf (ExprRange <none> <none>)), so at least one of them is buggy.

@dgrunwald
Copy link
Contributor

This is intentional in rustc. .. is only accepted as expression in locations where a..b would also be accepted.

That is, because the parentheses in &(a..b) are required, they are also required in &(..).

@brson
Copy link
Contributor

brson commented Apr 11, 2017

Seems like expected behavior to me.

@brson brson closed this as completed Apr 11, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-grammar Area: The grammar of Rust A-parser Area: The parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

4 participants