This commit is contained in:
mcarton 2016-02-15 13:25:29 +01:00
parent 1ca5903138
commit d755b1ebe2
3 changed files with 11 additions and 27 deletions

View File

@ -71,12 +71,9 @@ impl LintPass for Derive {
impl LateLintPass for Derive { impl LateLintPass for Derive {
fn check_item(&mut self, cx: &LateContext, item: &Item) { fn check_item(&mut self, cx: &LateContext, item: &Item) {
if_let_chain! {[ if_let_chain! {[
let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node
], { ], {
let ty = cx.tcx.lookup_item_type(cx.tcx.map.local_def_id(item.id)).ty; let ty = cx.tcx.lookup_item_type(cx.tcx.map.local_def_id(item.id)).ty;
if item.attrs.iter().any(is_automatically_derived) { if item.attrs.iter().any(is_automatically_derived) {
check_hash_peq(cx, item.span, trait_ref, ty); check_hash_peq(cx, item.span, trait_ref, ty);

View File

@ -35,6 +35,17 @@ impl Clone for Qux {
fn clone(&self) -> Self { Qux } fn clone(&self) -> Self { Qux }
} }
// See #666
#[derive(Copy)]
struct Lt<'a> {
a: &'a u8,
}
impl<'a> Clone for Lt<'a> {
//~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
fn clone(&self) -> Self { unimplemented!() }
}
// Ok, `Clone` cannot be derived because of the big array // Ok, `Clone` cannot be derived because of the big array
#[derive(Copy)] #[derive(Copy)]
struct BigArray { struct BigArray {

View File

@ -1,24 +0,0 @@
#![feature(plugin)]
#![plugin(clippy)]
pub struct Lt<'a> {
_foo: &'a u8,
}
impl<'a> Copy for Lt<'a> {}
impl<'a> Clone for Lt<'a> {
fn clone(&self) -> Lt<'a> {
unimplemented!();
}
}
pub struct Ty<A> {
_foo: A,
}
impl<A: Copy> Copy for Ty<A> {}
impl<A> Clone for Ty<A> {
fn clone(&self) -> Ty<A> {
unimplemented!();
}
}