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

Parser ambiguity with trait bounds and closure arguments #12778

Closed
alexcrichton opened this issue Mar 9, 2014 · 7 comments
Closed

Parser ambiguity with trait bounds and closure arguments #12778

alexcrichton opened this issue Mar 9, 2014 · 7 comments
Labels
A-grammar Area: The grammar of Rust
Milestone

Comments

@alexcrichton
Copy link
Member

When specifying a trait with a bound as a closure argument, there is currently a parser ambiguity:

trait Trait {}
fn foo(arg: |&Trait:Send|) {}

Is arg a closure that takes an argument of type Send, or does it take an argument of type &Trait:Send.

Nominating.

@pnkfelix
Copy link
Member

Assigning 1.0, P-backcompat-lang.

@pnkfelix pnkfelix added this to the 1.0 milestone Mar 13, 2014
@ben0x539
Copy link
Contributor

There's no reason to allow patterns for parameters in that position (outside of consistency), is there?

@nikomatsakis
Copy link
Contributor

This cropped up with extern fns. We chose to disallow patterns. Arguably we should do the same, but even then there is an ambiguity in a DST world, since |Trait:Send| would be a type. Perhaps the : syntax for bounded traits is just bad. Maybe we should use +, weird as it looks: |Trait+Send|, or else I personally like []: |Trait[Send]|.

@alexcrichton
Copy link
Member Author

There is also now an ambiguity with procs: |proc:Send()|

@nikomatsakis
Copy link
Contributor

proc is a keyword so I don't believe that is ambiguous, even if our parser treats keywords in a goofy way.

pcwalton added a commit to pcwalton/rust that referenced this issue May 22, 2014
This breaks some code that looked like `1 as u32 + 2`, because now `+`
is part of the type grammar. Change it to `(1 as u32) + 2`.

Part of rust-lang#12778.

[breaking-change]
@pcwalton
Copy link
Contributor

pcwalton commented Jun 9, 2014

RFC #87.

@alexcrichton
Copy link
Member Author

This will be addressed with RFC 27

pcwalton added a commit to pcwalton/rust that referenced this issue Jun 13, 2014
RFC rust-lang#27.

After a snapshot, the old syntax will be removed.

This can break some code that looked like `foo as &Trait:Send`. Now you
will need to write `foo as (&Trait+Send)`.

Closes rust-lang#12778.

[breaking-change]
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…t-generics, r=flodiebold

Support negative, `char` & `bool` const generics

Before:
![Before](https://user-images.githubusercontent.com/29541480/179379832-0c3b2a74-fef6-427e-b89f-7e31d9c37b3d.png)

After:
![After](https://user-images.githubusercontent.com/29541480/179379863-b62475dd-e7bf-41f2-b437-08dfe55951af.png)

I tried to implement stuff like `Const<{NUM1 + 3 + NUM2}>` by using already existing constant evaluation mechanism for ordinary constants, but turned out to be harder than I thought, maybe because I've never ever tinkered with compilers before
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…t-generics, r=Veykril

fix: un-inline `ConstScalarOrPath::from_expr_opt`

Sorry, but I missed these from rust-lang#12778 `@flodiebold`
flip1995 pushed a commit to flip1995/rust that referenced this issue May 17, 2024
…ntic, r=y21

`assigning_clones`: move to `pedantic` so it is allow by default

In a nutshell, the `assigning_clones` lint suggests to make your code less readable for a small performance gain. See rust-lang#12778 for more motivation.

fixes rust-lang#12778

changelog: [`assigning_clones`]: move to the `pedantic` group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust
Projects
None yet
Development

No branches or pull requests

5 participants