mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 11:12:43 +00:00
Don't suggest changing explicit Clone impls if they have generics
This commit is contained in:
parent
41a710e3f4
commit
1245de1e46
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
22
tests/ui/clone_on_copy_impl.rs
Normal file
22
tests/ui/clone_on_copy_impl.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::fmt;
|
||||
|
||||
pub struct Key<T> {
|
||||
#[doc(hidden)]
|
||||
pub __name: &'static str,
|
||||
#[doc(hidden)]
|
||||
pub __phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> Copy for Key<T> {}
|
||||
|
||||
impl<T> Clone for Key<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Key {
|
||||
__name: self.__name,
|
||||
__phantom: self.__phantom,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user