incorrect_clone_impl_on_copy_type false positive when macro-generated code doesn't know whether the type is Copy #11080
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
Consider this code using https://github.com/dtolnay/ghost:
This expands to a
pub type MyPhantom
andimpl Clone for MyPhantom
.That
impl Clone
needs to emit the same code regardless of whether the caller of this macro has handwrittenimpl<T> Copy for MyPhantom<T> {}
somewhere else in this crate. The attribute macro can't possibly know whether they have.So the macro can't produce
fn clone(&self) -> Self { *self }
because the type may or may not beCopy
.But if it produces
fn clone(&self) -> Self { /* other correct implementation */ }
and the type happens to beCopy
, then Clippy's incorrect_clone_impl_on_copy_type lint will be sad about this.Would this situation be worth documenting as a "known issue" for the lint?
Lint Name
incorrect_clone_impl_on_copy_type
Reproducer
No response
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: