]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsized/unsized-enum2.rs
Move /src/test to /tests
[rust.git] / tests / ui / unsized / unsized-enum2.rs
1 use std::ops::Deref;
2
3 // Due to aggressive error message deduplication, we require 20 *different*
4 // unsized types (even Path and [u8] are considered the "same").
5
6 trait Foo {}
7 trait Bar {}
8 trait FooBar {}
9 trait BarFoo {}
10
11 trait PathHelper1 {}
12 trait PathHelper2 {}
13 trait PathHelper3 {}
14 trait PathHelper4 {}
15
16 struct Path1(dyn PathHelper1);
17 struct Path2(dyn PathHelper2);
18 struct Path3(dyn PathHelper3);
19 struct Path4(dyn PathHelper4);
20
21 enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
22     // parameter
23     VA(W),
24     //~^ ERROR the size for values of type
25     VB{x: X},
26     //~^ ERROR the size for values of type
27     VC(isize, Y),
28     //~^ ERROR the size for values of type
29     VD{u: isize, x: Z},
30     //~^ ERROR the size for values of type
31
32     // slice / str
33     VE([u8]),
34     //~^ ERROR the size for values of type
35     VF{x: str},
36     //~^ ERROR the size for values of type
37     VG(isize, [f32]),
38     //~^ ERROR the size for values of type
39     VH{u: isize, x: [u32]},
40     //~^ ERROR the size for values of type
41
42     // unsized struct
43     VI(Path1),
44     //~^ ERROR the size for values of type
45     VJ{x: Path2},
46     //~^ ERROR the size for values of type
47     VK(isize, Path3),
48     //~^ ERROR the size for values of type
49     VL{u: isize, x: Path4},
50     //~^ ERROR the size for values of type
51
52     // plain trait
53     VM(dyn Foo),
54     //~^ ERROR the size for values of type
55     VN{x: dyn Bar},
56     //~^ ERROR the size for values of type
57     VO(isize, dyn FooBar),
58     //~^ ERROR the size for values of type
59     VP{u: isize, x: dyn BarFoo},
60     //~^ ERROR the size for values of type
61
62     // projected
63     VQ(<&'static [i8] as Deref>::Target),
64     //~^ ERROR the size for values of type
65     VR{x: <&'static [char] as Deref>::Target},
66     //~^ ERROR the size for values of type
67     VS(isize, <&'static [f64] as Deref>::Target),
68     //~^ ERROR the size for values of type
69     VT{u: isize, x: <&'static [i32] as Deref>::Target},
70     //~^ ERROR the size for values of type
71 }
72
73
74 fn main() { }