2014-06-20 23:16:14 -05:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2014-06-20 23:16:14 -05:00
|
|
|
#![allow(dead_code)]
|
2015-02-15 02:52:21 -06:00
|
|
|
|
|
|
|
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
2014-06-20 23:16:14 -05:00
|
|
|
|
2015-02-12 09:29:52 -06:00
|
|
|
trait Foo { fn dummy(&self) { } }
|
2014-06-20 23:16:14 -05:00
|
|
|
impl Foo for int {}
|
2014-12-19 20:20:51 -06:00
|
|
|
fn foo(_: [&Foo; 2]) {}
|
2014-06-20 23:16:14 -05:00
|
|
|
fn foos(_: &[&Foo]) {}
|
|
|
|
fn foog<T>(_: &[T], _: &[T]) {}
|
|
|
|
|
2014-12-19 20:20:51 -06:00
|
|
|
fn bar(_: [Box<Foo>; 2]) {}
|
2014-06-20 23:16:14 -05:00
|
|
|
fn bars(_: &[Box<Foo>]) {}
|
|
|
|
|
|
|
|
fn main() {
|
2015-01-25 15:05:03 -06:00
|
|
|
let x: [&Foo; 2] = [&1, &2];
|
2014-06-20 23:16:14 -05:00
|
|
|
foo(x);
|
2015-01-25 15:05:03 -06:00
|
|
|
foo([&1, &2]);
|
2014-06-20 23:16:14 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
let r = &1;
|
2014-12-19 20:20:51 -06:00
|
|
|
let x: [&Foo; 2] = [r; 2];
|
2014-06-20 23:16:14 -05:00
|
|
|
foo(x);
|
2015-01-25 15:05:03 -06:00
|
|
|
foo([&1; 2]);
|
2014-06-20 23:16:14 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
let x: &[&Foo] = &[&1, &2];
|
2014-06-20 23:16:14 -05:00
|
|
|
foos(x);
|
2015-01-25 15:05:03 -06:00
|
|
|
foos(&[&1, &2]);
|
2014-06-20 23:16:14 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
let x: &[&Foo] = &[&1, &2];
|
|
|
|
let r = &1;
|
2014-06-20 23:16:14 -05:00
|
|
|
foog(x, &[r]);
|
|
|
|
|
2015-02-15 02:52:21 -06:00
|
|
|
let x: [Box<Foo>; 2] = [Box::new(1), Box::new(2)];
|
2014-06-20 23:16:14 -05:00
|
|
|
bar(x);
|
2015-02-15 02:52:21 -06:00
|
|
|
bar([Box::new(1), Box::new(2)]);
|
2014-06-20 23:16:14 -05:00
|
|
|
|
2015-02-15 02:52:21 -06:00
|
|
|
let x: &[Box<Foo>] = &[Box::new(1), Box::new(2)];
|
2014-06-20 23:16:14 -05:00
|
|
|
bars(x);
|
2015-02-15 02:52:21 -06:00
|
|
|
bars(&[Box::new(1), Box::new(2)]);
|
2014-06-20 23:16:14 -05:00
|
|
|
|
2015-02-15 02:52:21 -06:00
|
|
|
let x: &[Box<Foo>] = &[Box::new(1), Box::new(2)];
|
|
|
|
foog(x, &[Box::new(1)]);
|
2014-06-20 23:16:14 -05:00
|
|
|
|
|
|
|
struct T<'a> {
|
2014-12-19 20:20:51 -06:00
|
|
|
t: [&'a (Foo+'a); 2]
|
2014-06-20 23:16:14 -05:00
|
|
|
}
|
|
|
|
let _n = T {
|
2015-01-25 15:05:03 -06:00
|
|
|
t: [&1, &2]
|
2014-06-20 23:16:14 -05:00
|
|
|
};
|
2015-01-25 15:05:03 -06:00
|
|
|
let r = &1;
|
2014-06-20 23:16:14 -05:00
|
|
|
let _n = T {
|
2014-12-19 20:20:51 -06:00
|
|
|
t: [r; 2]
|
2014-06-20 23:16:14 -05:00
|
|
|
};
|
2015-01-25 15:05:03 -06:00
|
|
|
let x: [&Foo; 2] = [&1, &2];
|
2014-06-20 23:16:14 -05:00
|
|
|
let _n = T {
|
|
|
|
t: x
|
|
|
|
};
|
|
|
|
|
|
|
|
struct F<'b> {
|
2014-11-20 14:08:02 -06:00
|
|
|
t: &'b [&'b (Foo+'b)]
|
2014-06-20 23:16:14 -05:00
|
|
|
}
|
|
|
|
let _n = F {
|
2015-01-25 15:05:03 -06:00
|
|
|
t: &[&1, &2]
|
2014-06-20 23:16:14 -05:00
|
|
|
};
|
2015-01-25 15:05:03 -06:00
|
|
|
let r = &1;
|
2014-12-19 20:20:51 -06:00
|
|
|
let r: [&Foo; 2] = [r; 2];
|
2014-06-20 23:16:14 -05:00
|
|
|
let _n = F {
|
2014-11-17 02:39:01 -06:00
|
|
|
t: &r
|
2014-06-20 23:16:14 -05:00
|
|
|
};
|
2015-01-25 15:05:03 -06:00
|
|
|
let x: [&Foo; 2] = [&1, &2];
|
2014-06-20 23:16:14 -05:00
|
|
|
let _n = F {
|
2014-11-17 02:39:01 -06:00
|
|
|
t: &x
|
2014-06-20 23:16:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct M<'a> {
|
2014-08-27 20:46:52 -05:00
|
|
|
t: &'a [Box<Foo+'static>]
|
2014-06-20 23:16:14 -05:00
|
|
|
}
|
|
|
|
let _n = M {
|
2015-02-15 02:52:21 -06:00
|
|
|
t: &[Box::new(1), Box::new(2)]
|
2014-06-20 23:16:14 -05:00
|
|
|
};
|
2015-02-15 02:52:21 -06:00
|
|
|
let x: [Box<Foo>; 2] = [Box::new(1), Box::new(2)];
|
2014-06-20 23:16:14 -05:00
|
|
|
let _n = M {
|
2014-11-17 02:39:01 -06:00
|
|
|
t: &x
|
2014-06-20 23:16:14 -05:00
|
|
|
};
|
|
|
|
}
|