-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Requires Copy
constraint on parametrized struct that is already known to #[derive(Copy)]
#32872
Comments
This is a limitation of derive, you can just do |
I just tried that:
but I received the same error on this impl line. |
Ah, right, that's because the same limitation affects |
And both Copy and Clone need manual implementations here. (Clone can reuse Copy though). |
It's strange that But sure enough, as it says https://doc.rust-lang.org/std/marker/trait.Copy.html
Thanks for the clarification. |
Duplicate of #26925, thanks for filing! |
@huonw My last message is related to the bug you marked this as a dupe of. But isn't the original bug reported here different? The error says
But it is implement right above it in my example up top. So some information is not being propagated correctly. |
@marcianx, oh, sorry, you are correct that this seems different! |
So looking at the expanded code, it looks like the problem is with the impl of Copy for I'm thinking we should close this as not really possible to fix, but since I'm uncertain, I'll leave open for the time being. Perhaps someone more familiar with this code could comment? Otherwise, I'll close in a week or two. // current impl
impl<'a, Meta: Copy + MyTrait> Copy for FwdIter<'a, Meta>
where Meta::AssocType: 'a { }
// required impl
impl<'a, Meta: Copy + MyTrait> Copy for FwdIter<'a, Meta>
where Meta::AssocType: Copy + 'a { } |
Closing in favor of #26925. |
Playground
Private struct
IterBase
is known to implementCopy
for all types it supports. However,#[derive(Copy)]
for public structFwdIter
(which simply wrapsIterBase
) gives the following error:One workaround is to make
IterBase
public and explicitly addIterBase<'a, Meta>: Copy
to thewhere
clause ofFwdIter
(and all itsimpl
s).The text was updated successfully, but these errors were encountered: