-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Sugared paths to associated types via non-variable types #19559
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
Comments
…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.
Triage: trying to figure out what this was about:
errors:
So I'm either misunderstanding something, or things have changed since this was opened. @nrc , which is it? |
e.g.,
Today, we get an ambiguity error, but there is no ambiguity here. |
There is some potential ambiguity here. pub trait T2 {
type U;
}
impl T2 for S {
type U = isize;
} The compiler can't determine if the type is |
I'm not sure this is worth implementing. Making |
Closing. I think that the decisions that need to be made with regards to ambiguity make closing this for the time being the best option. It's unclear that there are any significant wins, especially since this feature would make it more confusing to see This works already with bounds that clear up ambiguity, as below: struct T;
trait A {
type Type;
fn create(&self) -> Self::Type;
}
impl A for T {
type Type = i32;
fn create(&self) -> Self::Type {
10
}
}
fn t<X: A>(x: X) -> X::Type {
x.create()
}
fn main() {} |
thanks to nrc commented from Jan 1, 2016 |
internal: Switch to Rust 1.86.0
E.g.,
Foo::A
whereFoo
is a struct andA
is an associated type on one of its impls, orint::A
. (CurrentlyT::A
only works whereT
is a type parameter orSelf
).The text was updated successfully, but these errors were encountered: