]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unsized5.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / unsized5.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` types not allowed in fields (except the last one).
12
13 struct S1<X: ?Sized> {
14     f1: X,
15     //~^ ERROR the size for values of type
16     f2: isize,
17 }
18 struct S2<X: ?Sized> {
19     f: isize,
20     g: X,
21     //~^ ERROR the size for values of type
22     h: isize,
23 }
24 struct S3 {
25     f: str,
26     //~^ ERROR the size for values of type
27     g: [usize]
28 }
29 struct S4 {
30     f: [u8],
31     //~^ ERROR the size for values of type
32     g: usize
33 }
34 enum E<X: ?Sized> {
35     V1(X, isize),
36     //~^ ERROR the size for values of type
37 }
38 enum F<X: ?Sized> {
39     V2{f1: X, f: isize},
40     //~^ ERROR the size for values of type
41 }
42
43 pub fn main() {
44 }