]> git.lizzy.rs Git - rust.git/blob - tests/ui/large_enum_variant.rs
Change large_enum_variant to lint against size differences rather than size
[rust.git] / tests / ui / large_enum_variant.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![allow(dead_code)]
5 #![allow(unused_variables)]
6 #![deny(large_enum_variant)]
7
8 enum LargeEnum {
9     A(i32),
10     B([i32; 8000]), //~ ERROR large size difference between variants
11     //~^ HELP consider boxing the large fields to reduce the total size of the enum
12     //~| SUGGESTION Box<[i32; 8000]>
13 }
14
15 enum GenericEnumOk<T> {
16     A(i32),
17     B([T; 8000]),
18 }
19
20 enum GenericEnum2<T> {
21     A(i32),
22     B([i32; 8000]),
23     C(T, [i32; 8000]), //~ ERROR large size difference between variants
24     //~^ HELP consider boxing the large fields to reduce the total size of the enum
25 }
26
27 trait SomeTrait {
28     type Item;
29 }
30
31 enum LargeEnumGeneric<A: SomeTrait> {
32     Var(A::Item), // regression test, this used to ICE
33 }
34
35 enum LargeEnum2 {
36     VariantOk(i32, u32),
37     ContainingLargeEnum(LargeEnum), //~ ERROR large size difference between variants
38     //~^ HELP consider boxing the large fields to reduce the total size of the enum
39     //~| SUGGESTION Box<LargeEnum>
40 }
41 enum LargeEnum3 {
42     ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), //~ ERROR large size difference between variants
43     //~^ HELP consider boxing the large fields to reduce the total size of the enum
44     VoidVariant,
45     StructLikeLittle { x: i32, y: i32 },
46 }
47
48 enum LargeEnum4 {
49     VariantOk(i32, u32),
50     StructLikeLarge { x: [i32; 8000], y: i32 }, //~ ERROR large size difference between variants
51     //~^ HELP consider boxing the large fields to reduce the total size of the enum
52 }
53
54 enum LargeEnum5 {
55     VariantOk(i32, u32),
56     StructLikeLarge2 { //~ ERROR large size difference between variants
57         x:
58         [i32; 8000] //~ SUGGESTION Box<[i32; 8000]>
59         //~^ HELP consider boxing the large fields to reduce the total size of the enum
60     },
61 }
62
63 enum LargeEnumOk {
64     LargeA([i32; 8000]),
65     LargeB([i32; 8001]),
66 }
67
68 fn main() {
69
70 }