You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0223]: ambiguous associated type
--> <anon>:6:26
|
6 | fn do_something() -> Self::MyType::X;
| ^^^^^^^^^^^^^^^ ambiguous associated type
|
= note: specify the type using the syntax `<<Self as MyTrait>::MyType as Trait>::X`
Then I open docs which say
trait MyTrait {type X; }
fn main() {
let foo: MyTrait::X;
}
The problem here is that we're attempting to take the type of X from MyTrait.
Unfortunately, the type of X is not defined, because it's only made concrete in
implementations of the trait. A working version of this code might look like:
Whoa, in my example it seems pretty obvious which type X I mean. It works when I use the suggestion from error message, but the syntax seems too verbose for this context.
Is it a bug? Am I missing something here?
error[E0223]: ambiguous associated type
--> <anon>:13:25
|
13 | fn run<T: MyTrait>() -> T::MyType::X {
| ^^^^^^^^^^^^ ambiguous associated type
|
= note: specify the type using the syntax `<<T as MyTrait>::MyType as Trait>::X`
The text was updated successfully, but these errors were encountered:
Consider following example:
It fails with
Then I open docs which say
Whoa, in my example it seems pretty obvious which type
X
I mean. It works when I use the suggestion from error message, but the syntax seems too verbose for this context.Is it a bug? Am I missing something here?
Another example:
Fails with
The text was updated successfully, but these errors were encountered: