From b82f43f38e4f3ca4eba2261e7d2a9dcc81f9a7bb Mon Sep 17 00:00:00 2001 From: mcarton Date: Sun, 4 Sep 2016 17:39:48 +0200 Subject: [PATCH] Revert "Remove all `union` stuffs" This reverts commit 888c34ad70e9f4491a404c4f0cb5a6241e4a12c1. This rustups to rustc 1.13.0-nightly (70598e04f 2016-09-03). --- clippy_lints/src/derive.rs | 2 +- clippy_lints/src/len_zero.rs | 4 ++-- clippy_lints/src/missing_doc.rs | 2 +- tests/compile-fail/derive.rs | 4 +--- tests/compile-fail/no_effect.rs | 6 ++---- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 2311df424..17d17a445 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -141,7 +141,7 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref } match ty.sty { - //FIXME:unions: TypeVariants::TyUnion(..) => return, + TypeVariants::TyUnion(..) => return, // Some types are not Clone by default but could be cloned “by hand” if necessary TypeVariants::TyEnum(def, substs) | diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index fbcae0878..f574e6b7f 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -215,8 +215,8 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool { } ty::TyProjection(_) => ty.ty_to_def_id().map_or(false, |id| has_is_empty_impl(cx, &id)), ty::TyEnum(id, _) | - ty::TyStruct(id, _) /*FIXME:unions: | - ty::TyUnion(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, } diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index bd6354ad9..454f59175 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -123,7 +123,7 @@ impl LateLintPass for MissingDoc { hir::ItemStruct(..) => "a struct", hir::ItemTrait(..) => "a trait", hir::ItemTy(..) => "a type alias", - //FIXME:unions: hir::ItemUnion(..) => "a union", + hir::ItemUnion(..) => "a union", hir::ItemDefaultImpl(..) | hir::ItemExternCrate(..) | hir::ItemForeignMod(..) | diff --git a/tests/compile-fail/derive.rs b/tests/compile-fail/derive.rs index 39d9dde28..cf4467f30 100644 --- a/tests/compile-fail/derive.rs +++ b/tests/compile-fail/derive.rs @@ -1,7 +1,7 @@ #![feature(plugin)] #![plugin(clippy)] -//FIXME:unions: #![feature(untagged_unions)] +#![feature(untagged_unions)] #![deny(warnings)] #![allow(dead_code)] @@ -47,7 +47,6 @@ impl Clone for Qux { fn clone(&self) -> Self { Qux } } -/* FIXME:unions // looks like unions don't support deriving Clone for now #[derive(Copy)] union Union { @@ -61,7 +60,6 @@ impl Clone for Union { } } } -*/ // See #666 #[derive(Copy)] diff --git a/tests/compile-fail/no_effect.rs b/tests/compile-fail/no_effect.rs index 39b59a599..6616f7bdc 100644 --- a/tests/compile-fail/no_effect.rs +++ b/tests/compile-fail/no_effect.rs @@ -4,7 +4,7 @@ #![deny(no_effect, unnecessary_operation)] #![allow(dead_code)] #![allow(path_statements)] -//FIXME:unions #![feature(untagged_unions)] +#![feature(untagged_unions)] struct Unit; struct Tuple(i32); @@ -16,12 +16,10 @@ enum Enum { Struct { field: i32 }, } -/*FIXME:unions: union Union { a: u8, b: f64, } -*/ fn get_number() -> i32 { 0 } fn get_struct() -> Struct { Struct { field: 0 } } @@ -38,7 +36,7 @@ fn main() { Tuple(0); //~ERROR statement with no effect Struct { field: 0 }; //~ERROR statement with no effect Struct { ..s }; //~ERROR statement with no effect - //FIXME:unions: Union { a: 0 }; // /**FIXME*~***/ 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