Don't suggest changing explicit Clone impls if they have generics

This commit is contained in:
Oliver Schneider 2018-01-11 10:28:42 +01:00
parent 41a710e3f4
commit 1245de1e46
No known key found for this signature in database
GPG Key ID: A69F8D225B3AD7D9
2 changed files with 29 additions and 0 deletions

View File

@ -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;
}
}
}
},
_ => (),
}

View 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() {}