Skip to content

<T as Trait>::X::Y fails to parse #22139

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

Closed
huonw opened this issue Feb 10, 2015 · 2 comments
Closed

<T as Trait>::X::Y fails to parse #22139

huonw opened this issue Feb 10, 2015 · 2 comments
Labels
A-associated-items Area: Associated items (types, constants & functions)

Comments

@huonw
Copy link
Member

huonw commented Feb 10, 2015

trait Foo {
    type X;
}
trait Bar {
    type Y;
}

fn foo<T>(_: <T as Foo>::X::Y) 
    where T: Foo,
          T::X: Bar,
{}
<anon>:8:27: 8:29 error: expected one of `+` or `,`, found `::`
<anon>:8 fn foo<T>(_: <T as Foo>::X::Y) 
                                   ^~
@huonw huonw added the A-associated-items Area: Associated items (types, constants & functions) label Feb 10, 2015
bors added a commit that referenced this issue May 12, 2015
…atsakis

It is currently broken to use syntax such as `<T as Foo>::U::static_method()` where `<T as Foo>::U` is an associated type. I was able to fix this and simplify the parser a bit at the same time.

This also fixes the corresponding issue with associated types (#22139), but that's somewhat irrelevant because #22519 is still open, so this syntax still causes an error in type checking.

Similarly, although this fix applies to associated consts, #25046 forbids associated constants from using type parameters or `Self`, while #19559 means that associated types have to always have one of those two. Therefore, I think that you can't use an associated const from an associated type anyway.
@apasel422
Copy link
Contributor

This now causes the following error, which I think means this issue can be closed:

error: ambiguous associated type; specify the type using the syntax `<<T as Foo>::X as Trait>::Y` [E0223]

@steveklabnik
Copy link
Member

Agreed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions)
Projects
None yet
Development

No branches or pull requests

3 participants