-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Implementations conflict when using associated type across crates #51445
Comments
The names of the types don't have to be the same, and... when the associated type is not public, there is no workaround AFAICT. I ran into this while trying to implement |
I think the issue here is that A possible (but not easy) change in the language would be to mark the associated type as stable under non-breaking changes. The type system can then prove that there will be no conflicing implementation under non-breaking changes and can accept the code. I think the error message this issue generates in unclear. It did cost me a few days to narrow the error down to this issue. A better error message would have helped me here. |
I ran into this, including a completely wrong and unhelpful error, basically where I was I don't see how this isn't a bug. |
Changing a type in your API is already considered a major breaking change, so I don't think that's a factor. I noted a couple dupes; there was a PR that passed review for #85898, but it ran into some CI problems and got dropped. impl<'a> GatLike<'a, String> for Foo {
type Ref = &'a String;
}
impl<'a> GatLike<'a, <String as Deref>::Target> for Foo {
type Ref = &'a <String as Deref>::Target;
} It's quite annoying in a macro context, where now I have to manually supply the normalized types. Search aids: Associated type projection, normalization. While I feel this is a bug that should be fixed, the error is also counter-factual, so |
crate bar:
crate foo:
Output:
I can only reproduce this issue when using the
<Bar as SomeTrait>::Next
syntax, and only when Bar is in an external crate. Reproduced in current stable and nightly.The text was updated successfully, but these errors were encountered: