]> git.proxmox.com Git - rustc.git/blob - src/test/ui/enum/enum-size-variance.rs
Update upstream source from tag 'upstream/1.30.0_beta.7+dfsg1'
[rustc.git] / src / test / ui / enum / enum-size-variance.rs
1 // Copyright 2014 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.
4 //
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.
10
11 // run-pass
12
13 #![warn(variant_size_differences)]
14 #![allow(dead_code)]
15
16 // Note that the following test works because all fields of the enum variants are of the same size.
17 // If this test is modified and the reordering logic in librustc/ty/layout.rs kicks in, it fails.
18
19 enum Enum1 { }
20
21 enum Enum2 { A, B, C }
22
23 enum Enum3 { D(i64), E, F }
24
25 enum Enum4 { H(i64), I(i64), J }
26
27 enum Enum5 {
28 L(i64, i64, i64, i64), //~ WARNING three times larger
29 M(i64),
30 N
31 }
32
33 enum Enum6<T, U> {
34 O(T),
35 P(U),
36 Q(i64)
37 }
38
39 #[allow(variant_size_differences)]
40 enum Enum7 {
41 R(i64, i64, i64, i64),
42 S(i64),
43 T
44 }
45 pub fn main() { }