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
Now that the stdlib is starting to use associated types, I decided to go back and adapt my code base to use them as well. While doing this, I hit a strange problem where the compiler seems to required multiple impls to satisfy a bound using an associated type. Here's a reduction of my use case:
#![feature(associated_types)]traitA{typeTA;}traitB<TB>{fnfoo(&self,t:TB) -> TB{
t
}}traitC<TC:A>:B<<TCasA>::TA>{}structX;implAforX{typeTA = i32;}structY;implC<X>forY{}// Both of these impls are required for successful compilationimplB<i32>forY{fnfoo(&self,t:i32) -> i32{println!("First");
t
}}implB<<XasA>::TA>forY// This impl doesn't appear to actually be used{fnfoo(&self,t:i32) -> i32{println!("Second");
t
}}fnmain(){let y = Y;
y.foo(5);// Prints "First"}
I don't fully understand all the issues surrounding associated types, so this may or may not be a dupe, but it didn't seem obviously similar to any. Here is my rustc version:
Now that the stdlib is starting to use associated types, I decided to go back and adapt my code base to use them as well. While doing this, I hit a strange problem where the compiler seems to required multiple impls to satisfy a bound using an associated type. Here's a reduction of my use case:
I don't fully understand all the issues surrounding associated types, so this may or may not be a dupe, but it didn't seem obviously similar to any. Here is my rustc version:
The text was updated successfully, but these errors were encountered: