]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-11205.rs
549a70f19e334fb166149f2cee556d6b55523ec5
[rust.git] / src / test / run-pass / issue-11205.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 #![allow(dead_code)]
12
13 trait Foo {}
14 impl Foo for int {}
15 fn foo(_: [&Foo; 2]) {}
16 fn foos(_: &[&Foo]) {}
17 fn foog<T>(_: &[T], _: &[T]) {}
18
19 fn bar(_: [Box<Foo>; 2]) {}
20 fn bars(_: &[Box<Foo>]) {}
21
22 fn main() {
23     let x: [&Foo; 2] = [&1i, &2i];
24     foo(x);
25     foo([&1i, &2i]);
26
27     let r = &1i;
28     let x: [&Foo; 2] = [r; 2];
29     foo(x);
30     foo([&1i; 2]);
31
32     let x: &[&Foo] = &[&1i, &2i];
33     foos(x);
34     foos(&[&1i, &2i]);
35
36     let x: &[&Foo] = &[&1i, &2i];
37     let r = &1i;
38     foog(x, &[r]);
39
40     let x: [Box<Foo>; 2] = [box 1i, box 2i];
41     bar(x);
42     bar([box 1i, box 2i]);
43
44     let x: &[Box<Foo>] = &[box 1i, box 2i];
45     bars(x);
46     bars(&[box 1i, box 2i]);
47
48     let x: &[Box<Foo>] = &[box 1i, box 2i];
49     foog(x, &[box 1i]);
50
51     struct T<'a> {
52         t: [&'a (Foo+'a); 2]
53     }
54     let _n = T {
55         t: [&1i, &2i]
56     };
57     let r = &1i;
58     let _n = T {
59         t: [r; 2]
60     };
61     let x: [&Foo; 2] = [&1i, &2i];
62     let _n = T {
63         t: x
64     };
65
66     struct F<'b> {
67         t: &'b [&'b (Foo+'b)]
68     }
69     let _n = F {
70         t: &[&1i, &2i]
71     };
72     let r = &1i;
73     let r: [&Foo; 2] = [r; 2];
74     let _n = F {
75         t: &r
76     };
77     let x: [&Foo; 2] = [&1i, &2i];
78     let _n = F {
79         t: &x
80     };
81
82     struct M<'a> {
83         t: &'a [Box<Foo+'static>]
84     }
85     let _n = M {
86         t: &[box 1i, box 2i]
87     };
88     let x: [Box<Foo>; 2] = [box 1i, box 2i];
89     let _n = M {
90         t: &x
91     };
92 }