Incorrect #derive(Clone, Copy)
for structs containing references
#117747
Labels
C-bug
Category: This is a bug.
#derive(Clone, Copy)
for structs containing references
#117747
Shared references are
Copy
no matter what they point to, so deriving copy on a struct containing such a reference works fine:Then, because
Foo
now implementsCopy
, I expected this to workInstead, this happens:
Meta
This is reproduced on stable 1.73.0, and on nightly on the playground
Additional note:
If I add the
T: Copy
bound, the compiler stops complaining, but it shouldn't be needed (and in practice my types themselves aren't evenCopy
)Edit:
The macro expansion seems to be the source of the problem, inserting a gratuitous
Clone
andCopy
bounds to the generic parameter.Whereas manually implementing
Clone
andCopy
works fine as expectedThe text was updated successfully, but these errors were encountered: