-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
// This file tests repr(transparent)-related errors reported during typeck. Other errors
// that are reported earlier and therefore preempt these are tested in:
// - repr-transparent-other-reprs.rs
// - repr-transparent-other-items.rs
-#![feature(repr_align)]
+#![feature(repr_align, transparent_enums, transparent_unions)]
use std::marker::PhantomData;
#[repr(transparent)]
struct GenericAlign<T>(ZstAlign32<T>, u32); //~ ERROR alignment larger than 1
+
+#[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum
+enum Void {}
+//~^ ERROR transparent enum needs exactly one variant, but has 0
+
+#[repr(transparent)]
+enum FieldlessEnum { //~ ERROR transparent enum needs exactly one non-zero-sized field, but has 0
+ Foo,
+}
+
+#[repr(transparent)]
+enum TooManyFieldsEnum {
+ Foo(u32, String),
+}
+//~^^^ ERROR transparent enum needs exactly one non-zero-sized field, but has 2
+
+#[repr(transparent)]
+enum TooManyVariants { //~ ERROR transparent enum needs exactly one variant, but has 2
+ Foo(String),
+ Bar,
+}
+
+#[repr(transparent)]
+union UnitUnion { //~ ERROR transparent union needs exactly one non-zero-sized field, but has 0
+ u: (),
+}
+
+#[repr(transparent)]
+union TooManyFields { //~ ERROR transparent union needs exactly one non-zero-sized field, but has 2
+ u: u32,
+ s: i32
+}
+
+fn main() {}