-
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
non-Clone
type, with Clone
associated type, as type param leads to confusing behavior in #[derive(Clone)]
#124300
Comments
Clone
type, with Clone
associated type, as type param leads to confusing behavior Clone
type, with Clone
associated type, as type param leads to confusing behavior in #[derive(Clone)]
You are basically looking for perfect derive: |
impl<T: Clone/*<-- [!] */ + NotClone>Clone for ShouldBeClone<T>
where
T::AssocClonable: Clone,
{ /* ... */ } Meaning it generates a |
If want to get rid of the extra |
I see. So this is why it is able to compile and only error when I try to call |
Closing as duplicate of #26925. |
Exactly! |
Apart from https://crates.io/crates/perfect-derive, there's also https://lib.rs/crates/derivative if you don't want to write the impl manually where you can specify if you want to omit certain bounds with attributes. |
I tried this code:
the the two clones are uncommented
fails with
Instead, this happened:
either
ShouldBeClone::<NotCloneImpl>
can not be deriveClone
becauseNotCloneImpl
is notClone
NotCloneImpl::AssociatedCloneableType
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: