]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unsized6.rs
Rollup merge of #82259 - osa1:issue82156, r=petrochenkov
[rust.git] / src / test / ui / unsized6.rs
1 // Test `?Sized` local variables.
2
3 trait T {}
4
5 fn f1<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized>(x: &X) {
6     let _: W; // <-- this is OK, no bindings created, no initializer.
7     let _: (isize, (X, isize));
8     //~^ ERROR the size for values of type
9     let y: Y;
10     //~^ ERROR the size for values of type
11     let y: (isize, (Z, usize));
12     //~^ ERROR the size for values of type
13 }
14 fn f2<X: ?Sized, Y: ?Sized>(x: &X) {
15     let y: X;
16     //~^ ERROR the size for values of type
17     let y: (isize, (Y, isize));
18     //~^ ERROR the size for values of type
19 }
20
21 fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
22     let y: X = *x1;
23     //~^ ERROR the size for values of type
24     let y = *x2;
25     //~^ ERROR the size for values of type
26     let (y, z) = (*x3, 4);
27     //~^ ERROR the size for values of type
28 }
29 fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
30     let y: X = *x1;
31     //~^ ERROR the size for values of type
32     let y = *x2;
33     //~^ ERROR the size for values of type
34     let (y, z) = (*x3, 4);
35     //~^ ERROR the size for values of type
36 }
37
38 fn g1<X: ?Sized>(x: X) {}
39 //~^ ERROR the size for values of type
40 fn g2<X: ?Sized + T>(x: X) {}
41 //~^ ERROR the size for values of type
42
43 pub fn main() {
44 }