]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/enum-size-variance.rs
rustdoc: Hide `self: Box<Self>` in list of deref methods
[rust.git] / src / test / run-pass / 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 #![warn(variant_size_differences)]
12 #![allow(dead_code)]
13
14 // Note that the following test works because all fields of the enum variants are of the same size.
15 // If this test is modified and the reordering logic in librustc/ty/layout.rs kicks in, it fails.
16
17 enum Enum1 { }
18
19 enum Enum2 { A, B, C }
20
21 enum Enum3 { D(isize), E, F }
22
23 enum Enum4 { H(isize), I(isize), J }
24
25 enum Enum5 {
26     L(isize, isize, isize, isize), //~ WARNING three times larger
27     M(isize),
28     N
29 }
30
31 enum Enum6<T, U> {
32     O(T),
33     P(U),
34     Q(isize)
35 }
36
37 #[allow(variant_size_differences)]
38 enum Enum7 {
39     R(isize, isize, isize, isize),
40     S(isize),
41     T
42 }
43 pub fn main() { }