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

syntax: Add support for trait bounds on procs #12774

Merged
merged 1 commit into from
Mar 12, 2014

Conversation

alexcrichton
Copy link
Member

This is needed to make progress on #10296 as the default bounds will no longer
include Send. I believe that this was the originally intended syntax for procs,
and it just hasn't been necessary up until now.

@alexcrichton
Copy link
Member Author

Interestingly, this syntax leads to an ambiguity:

proc(proc:Send())

Is this parsed as a variable named proc with a type of Send(), or a procedure with a Send bound? Did we have another intended syntax for specifying bounds on procedures?

@huonw
Copy link
Member

huonw commented Mar 9, 2014

Isn't proc a keyword, and so not legal as a variable name?

@huonw
Copy link
Member

huonw commented Mar 9, 2014

I talked to @alexcrichton on IRC and he pointed out that the problem basically let x: |a: int| let x: |int| are both valid and equivalent, i.e. the former is just the latter with the argument named.

This means that, when parsing the internals of |proc:Send... (or proc(proc:Send) the parser sees the ident token proc and the : and assumes it's parsing a named argument even though the proc keyword is invalid to use as an argument name.

i.e. it's not necessarily an ambiguity, so much as an edgecase the compiler handles incorrectly. It seems a similar thing happens with let x: |&Trait:Send|, it parses &Trait as a pattern and gets confused by the use of the bare trait Send.

This is needed to make progress on rust-lang#10296 as the default bounds will no longer
include Send. I believe that this was the originally intended syntax for procs,
and it just hasn't been necessary up until now.
bors added a commit that referenced this pull request Mar 12, 2014
This is needed to make progress on #10296 as the default bounds will no longer
include Send. I believe that this was the originally intended syntax for procs,
and it just hasn't been necessary up until now.
@bors bors closed this Mar 12, 2014
@bors bors merged commit 7b4ee5c into rust-lang:master Mar 12, 2014
@alexcrichton alexcrichton deleted the proc-bounds branch March 12, 2014 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants