about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_lint/types.rs29
-rw-r--r--src/test/compile-fail/lint-ctypes-enum.rs12
2 files changed, 12 insertions, 29 deletions
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index b6e8ae96942..f17fa9c7ca1 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -26,7 +26,6 @@ use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
 
 use syntax::ast;
 use syntax::abi::Abi;
-use syntax::attr;
 use syntax_pos::Span;
 use syntax::codemap;
 
@@ -402,17 +401,6 @@ fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     false
 }
 
-fn is_ffi_safe(ty: attr::IntType) -> bool {
-    match ty {
-        attr::SignedInt(ast::IntTy::I8) | attr::UnsignedInt(ast::UintTy::U8) |
-        attr::SignedInt(ast::IntTy::I16) | attr::UnsignedInt(ast::UintTy::U16) |
-        attr::SignedInt(ast::IntTy::I32) | attr::UnsignedInt(ast::UintTy::U32) |
-        attr::SignedInt(ast::IntTy::I64) | attr::UnsignedInt(ast::UintTy::U64) |
-        attr::SignedInt(ast::IntTy::I128) | attr::UnsignedInt(ast::UintTy::U128) => true,
-        attr::SignedInt(ast::IntTy::Isize) | attr::UnsignedInt(ast::UintTy::Usize) => false
-    }
-}
-
 impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
     /// Check if the given type is "ffi-safe" (has a stable, well-defined
     /// representation which can be exported to C code).
@@ -546,23 +534,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
                             }
                         }
 
-                        if let Some(int_ty) = def.repr.int {
-                            if !is_ffi_safe(int_ty) {
-                                // FIXME: This shouldn't be reachable: we should check
-                                // this earlier.
-                                return FfiUnsafe(FfiError {
-                                    message: "enum has unexpected #[repr(...)] attribute",
-                                    help: None,
-                                });
-                            }
-
-                            // Enum with an explicitly sized discriminant; either
-                            // a C-style enum or a discriminated union.
-
-                            // The layout of enum variants is implicitly repr(C).
-                            // FIXME: Is that correct?
-                        }
-
                         // Check the contained variants.
                         for variant in &def.variants {
                             for field in &variant.fields {
diff --git a/src/test/compile-fail/lint-ctypes-enum.rs b/src/test/compile-fail/lint-ctypes-enum.rs
index e35dadbea9d..ce6afe1d219 100644
--- a/src/test/compile-fail/lint-ctypes-enum.rs
+++ b/src/test/compile-fail/lint-ctypes-enum.rs
@@ -16,11 +16,23 @@ enum U { A }
 enum B { C, D }
 enum T { E, F, G }
 
+#[repr(C)]
+enum ReprC { A, B, C }
+
+#[repr(u8)]
+enum U8 { A, B, C }
+
+#[repr(isize)]
+enum Isize { A, B, C }
+
 extern {
    fn zf(x: Z);
    fn uf(x: U); //~ ERROR found enum without foreign-function-safe
    fn bf(x: B); //~ ERROR found enum without foreign-function-safe
    fn tf(x: T); //~ ERROR found enum without foreign-function-safe
+   fn reprc(x: ReprC);
+   fn u8(x: U8);
+   fn isize(x: Isize);
 }
 
 pub fn main() { }