1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // This file tests repr(transparent)-related errors reported during typeck. Other errors
12 // that are reported earlier and therefore preempt these are tested in:
13 // - repr-transparent-other-reprs.rs
14 // - repr-transparent-other-items.rs
16 #![feature(repr_align)]
18 use std::marker::PhantomData;
21 struct NoFields; //~ ERROR needs exactly one non-zero-sized field
24 struct ContainsOnlyZst(()); //~ ERROR needs exactly one non-zero-sized field
27 struct ContainsOnlyZstArray([bool; 0]); //~ ERROR needs exactly one non-zero-sized field
30 struct ContainsMultipleZst(PhantomData<*const i32>, NoFields);
31 //~^ ERROR needs exactly one non-zero-sized field
34 struct MultipleNonZst(u8, u8); //~ ERROR needs exactly one non-zero-sized field
36 trait Mirror { type It: ?Sized; }
37 impl<T: ?Sized> Mirror for T { type It = Self; }
40 pub struct StructWithProjection(f32, <f32 as Mirror>::It);
41 //~^ ERROR needs exactly one non-zero-sized field
44 struct NontrivialAlignZst(u32, [u16; 0]); //~ ERROR alignment larger than 1
47 struct ZstAlign32<T>(PhantomData<T>);
50 struct GenericAlign<T>(ZstAlign32<T>, u32); //~ ERROR alignment larger than 1