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