]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/unsized2.rs
Ignore new test on Windows
[rust.git] / src / test / run-pass / unsized2.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 #![feature(box_syntax)]
12
13 // Test sized-ness checking in substitution.
14
15 use std::marker;
16
17 // Unbounded.
18 fn f1<X: ?Sized>(x: &X) {
19     f1::<X>(x);
20 }
21 fn f2<X>(x: &X) {
22     f1::<X>(x);
23     f2::<X>(x);
24 }
25
26 // Bounded.
27 trait T { fn dummy(&self) { } }
28 fn f3<X: T+?Sized>(x: &X) {
29     f3::<X>(x);
30 }
31 fn f4<X: T>(x: &X) {
32     f3::<X>(x);
33     f4::<X>(x);
34 }
35
36 // Self type.
37 trait T2 {
38     fn f() -> Box<Self>;
39 }
40 struct S;
41 impl T2 for S {
42     fn f() -> Box<S> {
43         box S
44     }
45 }
46 fn f5<X: ?Sized+T2>(x: &X) {
47     let _: Box<X> = T2::f();
48 }
49 fn f6<X: T2>(x: &X) {
50     let _: Box<X> = T2::f();
51 }
52
53 trait T3 {
54     fn f() -> Box<Self>;
55 }
56 impl T3 for S {
57     fn f() -> Box<S> {
58         box S
59     }
60 }
61 fn f7<X: ?Sized+T3>(x: &X) {
62     // This is valid, but the unsized bound on X is irrelevant because any type
63     // which implements T3 must have statically known size.
64     let _: Box<X> = T3::f();
65 }
66
67 trait T4<X> {
68     fn dummy(&self) { }
69     fn m1(&self, x: &T4<X>, y: X);
70     fn m2(&self, x: &T5<X>, y: X);
71 }
72 trait T5<X: ?Sized> {
73     fn dummy(&self) { }
74     // not an error (for now)
75     fn m1(&self, x: &T4<X>);
76     fn m2(&self, x: &T5<X>);
77 }
78
79 trait T6<X: T> {
80     fn dummy(&self) { }
81     fn m1(&self, x: &T4<X>);
82     fn m2(&self, x: &T5<X>);
83 }
84 trait T7<X: ?Sized+T> {
85     fn dummy(&self) { }
86     // not an error (for now)
87     fn m1(&self, x: &T4<X>);
88     fn m2(&self, x: &T5<X>);
89 }
90
91 // The last field in a struct may be unsized
92 struct S2<X: ?Sized> {
93     f: X,
94 }
95 struct S3<X: ?Sized> {
96     f1: isize,
97     f2: X,
98 }
99
100 pub fn main() {
101 }