]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unsized6.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / unsized6.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 // Test `?Sized` local variables.
12
13 trait T {}
14
15 fn f1<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized>(x: &X) {
16     let _: W; // <-- this is OK, no bindings created, no initializer.
17     let _: (isize, (X, isize));
18     //~^ ERROR the size for values of type
19     let y: Y;
20     //~^ ERROR the size for values of type
21     let y: (isize, (Z, usize));
22     //~^ ERROR the size for values of type
23 }
24 fn f2<X: ?Sized, Y: ?Sized>(x: &X) {
25     let y: X;
26     //~^ ERROR the size for values of type
27     let y: (isize, (Y, isize));
28     //~^ ERROR the size for values of type
29 }
30
31 fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
32     let y: X = *x1;
33     //~^ ERROR the size for values of type
34     let y = *x2;
35     //~^ ERROR the size for values of type
36     let (y, z) = (*x3, 4);
37     //~^ ERROR the size for values of type
38 }
39 fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
40     let y: X = *x1;
41     //~^ ERROR the size for values of type
42     let y = *x2;
43     //~^ ERROR the size for values of type
44     let (y, z) = (*x3, 4);
45     //~^ ERROR the size for values of type
46 }
47
48 fn g1<X: ?Sized>(x: X) {}
49 //~^ ERROR the size for values of type
50 fn g2<X: ?Sized + T>(x: X) {}
51 //~^ ERROR the size for values of type
52
53 pub fn main() {
54 }