diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 6ce67a9b05c..d327d0570f1 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -148,6 +148,13 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref return; } } + for subst in substs { + if let Some(subst) = subst.as_type() { + if let ty::TyParam(_) = subst.sty { + return; + } + } + } }, _ => (), } diff --git a/tests/ui/clone_on_copy_impl.rs b/tests/ui/clone_on_copy_impl.rs new file mode 100644 index 00000000000..e21441640f3 --- /dev/null +++ b/tests/ui/clone_on_copy_impl.rs @@ -0,0 +1,22 @@ +use std::marker::PhantomData; +use std::fmt; + +pub struct Key { + #[doc(hidden)] + pub __name: &'static str, + #[doc(hidden)] + pub __phantom: PhantomData, +} + +impl Copy for Key {} + +impl Clone for Key { + fn clone(&self) -> Self { + Key { + __name: self.__name, + __phantom: self.__phantom, + } + } +} + +fn main() {}