]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unsized3.rs
Auto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
[rust.git] / src / test / ui / unsized3.rs
1 // Test sized-ness checking in substitution within fn bodies..
2
3 use std::marker;
4
5 // Unbounded.
6 fn f1<X: ?Sized>(x: &X) {
7     f2::<X>(x);
8     //~^ ERROR the size for values of type
9 }
10 fn f2<X>(x: &X) {
11 }
12
13 // Bounded.
14 trait T {
15     fn foo(&self) { }
16 }
17 fn f3<X: ?Sized + T>(x: &X) {
18     f4::<X>(x);
19     //~^ ERROR the size for values of type
20 }
21 fn f4<X: T>(x: &X) {
22 }
23
24 fn f5<Y>(x: &Y) {}
25 fn f6<X: ?Sized>(x: &X) {}
26
27 // Test with unsized struct.
28 struct S<X: ?Sized> {
29     x: X,
30 }
31
32 fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
33     f5(x1);
34     //~^ ERROR the size for values of type
35     f6(x2); // ok
36 }
37
38 // Test some tuples.
39 fn f9<X: ?Sized>(x1: Box<S<X>>) {
40     f5(&(*x1, 34));
41     //~^ ERROR the size for values of type
42 }
43
44 fn f10<X: ?Sized>(x1: Box<S<X>>) {
45     f5(&(32, *x1));
46     //~^ ERROR the size for values of type
47     //~| ERROR the size for values of type
48 }
49
50 pub fn main() {
51 }