-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Rust cannot derive traits from associated types #34377
Comments
pub trait Foo {
type Type: Copy;
} While this will make it compile, it seems a bit strange the error would occur - it's true in the original the trait Foo doesn't have a Copy bound on Type, but the implementation of Bar resolves to a type that does have Copy implemented - and the error itself is seems to be about the implementation, not the trait. If this hasty error-throwing behavior is intentional, perhaps the error could be made to refer to the Foo trait? It feels like a bug. |
This is probably the same as #31518 |
It's kinda like #31518, but it's more that rust doesn't substitute the associated type before doing the pub trait Foo {
type Type;
}
pub struct Bar(<Bar as Foo>::Type);
impl Foo for Bar {
type Type = i8;
}
impl Copy for Bar {} //~ERROR the trait `Copy` may not be implemented |
It's not probably not normalizing associated types for this check. As far as I know, it's the only trait that has a check like that, so it's not that surprising that it's fallen through the cracks. |
Yeah, looking at the code, it doesn't look like it tries to resolve the associated type when checking that the impl of cc @rust-lang/compiler |
Baz is fine, Bar fails.
The text was updated successfully, but these errors were encountered: