return; // ty is not Copy
}
- // Some types are not Clone by default but could be cloned `by hand` if necessary
match ty.sty {
+ TypeVariants::TyUnion(..) => return,
+
+ // Some types are not Clone by default but could be cloned “by hand” if necessary
TypeVariants::TyEnum(def, substs) |
TypeVariants::TyStruct(def, substs) => {
for variant in &def.variants {
}
ty::TyProjection(_) => ty.ty_to_def_id().map_or(false, |id| has_is_empty_impl(cx, &id)),
ty::TyEnum(id, _) |
- ty::TyStruct(id, _) => has_is_empty_impl(cx, &id.did),
+ ty::TyStruct(id, _) |
+ ty::TyUnion(id, _) => has_is_empty_impl(cx, &id.did),
ty::TyArray(..) | ty::TyStr => true,
_ => false,
}
#![feature(plugin)]
#![plugin(clippy)]
+#![feature(untagged_unions)]
+
#![deny(warnings)]
#![allow(dead_code)]
fn clone(&self) -> Self { Qux }
}
+// looks like unions don't support deriving Clone for now
+#[derive(Copy)]
+union Union {
+ a: u8,
+}
+
+impl Clone for Union {
+ fn clone(&self) -> Self {
+ Union {
+ a: 42,
+ }
+ }
+}
+
// See #666
#[derive(Copy)]
struct Lt<'a> {
#![deny(no_effect, unnecessary_operation)]
#![allow(dead_code)]
#![allow(path_statements)]
+#![feature(untagged_unions)]
struct Unit;
struct Tuple(i32);
Struct { field: i32 },
}
+union Union {
+ a: u8,
+ b: f64,
+}
+
fn get_number() -> i32 { 0 }
fn get_struct() -> Struct { Struct { field: 0 } }
Tuple(0); //~ERROR statement with no effect
Struct { field: 0 }; //~ERROR statement with no effect
Struct { ..s }; //~ERROR statement with no effect
+ Union { a: 0 }; //~ERROR statement with no effect
Enum::Tuple(0); //~ERROR statement with no effect
Enum::Struct { field: 0 }; //~ERROR statement with no effect
5 + 6; //~ERROR statement with no effect