]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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-ness checking in substitution within fn bodies.. | |
12 | ||
85aaf69f | 13 | use std::marker; |
1a4d82fc JJ |
14 | |
15 | // Unbounded. | |
16 | fn f1<X: ?Sized>(x: &X) { | |
17 | f2::<X>(x); | |
54a0048b | 18 | //~^ ERROR `X: std::marker::Sized` is not satisfied |
1a4d82fc JJ |
19 | } |
20 | fn f2<X>(x: &X) { | |
21 | } | |
22 | ||
23 | // Bounded. | |
85aaf69f SL |
24 | trait T { |
25 | fn foo(&self) { } | |
26 | } | |
1a4d82fc JJ |
27 | fn f3<X: ?Sized + T>(x: &X) { |
28 | f4::<X>(x); | |
54a0048b | 29 | //~^ ERROR `X: std::marker::Sized` is not satisfied |
1a4d82fc JJ |
30 | } |
31 | fn f4<X: T>(x: &X) { | |
32 | } | |
33 | ||
34 | // Test with unsized enum. | |
35 | enum E<X: ?Sized> { | |
36 | V(X), | |
37 | } | |
38 | ||
39 | fn f5<Y>(x: &Y) {} | |
40 | fn f6<X: ?Sized>(x: &X) {} | |
41 | fn f7<X: ?Sized>(x1: &E<X>, x2: &E<X>) { | |
42 | f5(x1); | |
54a0048b | 43 | //~^ ERROR `X: std::marker::Sized` is not satisfied |
1a4d82fc JJ |
44 | f6(x2); // ok |
45 | } | |
46 | ||
47 | ||
48 | // Test with unsized struct. | |
49 | struct S<X: ?Sized> { | |
50 | x: X, | |
51 | } | |
52 | ||
53 | fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) { | |
54 | f5(x1); | |
54a0048b | 55 | //~^ ERROR `X: std::marker::Sized` is not satisfied |
1a4d82fc JJ |
56 | f6(x2); // ok |
57 | } | |
58 | ||
59 | // Test some tuples. | |
60 | fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) { | |
85aaf69f | 61 | f5(&(*x1, 34)); |
54a0048b | 62 | //~^ ERROR `X: std::marker::Sized` is not satisfied |
1a4d82fc JJ |
63 | } |
64 | ||
65 | fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) { | |
85aaf69f | 66 | f5(&(32, *x2)); |
54a0048b | 67 | //~^ ERROR `X: std::marker::Sized` is not satisfied |
1a4d82fc JJ |
68 | } |
69 | ||
70 | pub fn main() { | |
71 | } |