]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/regions-fn-subtyping.rs
rollup merge of #18407 : thestinger/arena
[rust.git] / src / test / compile-fail / regions-fn-subtyping.rs
1 // Copyright 2012 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 fn of<'a,T>() -> |T|:'a { panic!(); }
12 fn subtype<T>(x: |T|) { panic!(); }
13
14 fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
15     // Here, x, y, and z are free.  Other letters
16     // are bound.  Note that the arrangement
17     // subtype::<T1>(of::<T2>()) will typecheck
18     // iff T1 <: T2.
19
20     subtype::< <'a>|&'a T|>(
21         of::< <'a>|&'a T|>());
22
23     subtype::< <'a>|&'a T|>(
24         of::< <'b>|&'b T|>());
25
26     subtype::< <'b>|&'b T|>(
27         of::<|&'x T|>());
28
29     subtype::<|&'x T|>(
30         of::< <'b>|&'b T|>());  //~ ERROR mismatched types
31
32     subtype::< <'a,'b>|&'a T, &'b T|>(
33         of::< <'a>|&'a T, &'a T|>());
34
35     subtype::< <'a>|&'a T, &'a T|>(
36         of::< <'a,'b>|&'a T, &'b T|>()); //~ ERROR mismatched types
37
38     subtype::< <'a,'b>|&'a T, &'b T|>(
39         of::<|&'x T, &'y T|>());
40
41     subtype::<|&'x T, &'y T|>(
42         of::< <'a,'b>|&'a T, &'b T|>()); //~ ERROR mismatched types
43 }
44
45 fn main() {}