2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2014-06-21 04:16:14 +00:00
|
|
|
#![allow(dead_code)]
|
2015-02-15 08:52:21 +00:00
|
|
|
|
2015-02-12 15:29:52 +00:00
|
|
|
trait Foo { fn dummy(&self) { } }
|
2015-03-26 00:06:52 +00:00
|
|
|
impl Foo for isize {}
|
2019-05-28 18:47:21 +00:00
|
|
|
fn foo(_: [&dyn Foo; 2]) {}
|
|
|
|
fn foos(_: &[&dyn Foo]) {}
|
2014-06-21 04:16:14 +00:00
|
|
|
fn foog<T>(_: &[T], _: &[T]) {}
|
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
fn bar(_: [Box<dyn Foo>; 2]) {}
|
|
|
|
fn bars(_: &[Box<dyn Foo+'static>]) {}
|
2014-06-21 04:16:14 +00:00
|
|
|
|
|
|
|
fn main() {
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: [&dyn Foo; 2] = [&1, &2];
|
2014-06-21 04:16:14 +00:00
|
|
|
foo(x);
|
2015-01-25 21:05:03 +00:00
|
|
|
foo([&1, &2]);
|
2014-06-21 04:16:14 +00:00
|
|
|
|
2015-01-25 21:05:03 +00:00
|
|
|
let r = &1;
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: [&dyn Foo; 2] = [r; 2];
|
2014-06-21 04:16:14 +00:00
|
|
|
foo(x);
|
2015-01-25 21:05:03 +00:00
|
|
|
foo([&1; 2]);
|
2014-06-21 04:16:14 +00:00
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: &[&dyn Foo] = &[&1, &2];
|
2014-06-21 04:16:14 +00:00
|
|
|
foos(x);
|
2015-01-25 21:05:03 +00:00
|
|
|
foos(&[&1, &2]);
|
2014-06-21 04:16:14 +00:00
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: &[&dyn Foo] = &[&1, &2];
|
2015-01-25 21:05:03 +00:00
|
|
|
let r = &1;
|
2014-06-21 04:16:14 +00:00
|
|
|
foog(x, &[r]);
|
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: [Box<dyn Foo>; 2] = [Box::new(1), Box::new(2)];
|
2014-06-21 04:16:14 +00:00
|
|
|
bar(x);
|
2015-02-15 08:52:21 +00:00
|
|
|
bar([Box::new(1), Box::new(2)]);
|
2014-06-21 04:16:14 +00:00
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: &[Box<dyn Foo+'static>] = &[Box::new(1), Box::new(2)];
|
2014-06-21 04:16:14 +00:00
|
|
|
bars(x);
|
2015-02-15 08:52:21 +00:00
|
|
|
bars(&[Box::new(1), Box::new(2)]);
|
2014-06-21 04:16:14 +00:00
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: &[Box<dyn Foo+'static>] = &[Box::new(1), Box::new(2)];
|
2015-02-15 08:52:21 +00:00
|
|
|
foog(x, &[Box::new(1)]);
|
2014-06-21 04:16:14 +00:00
|
|
|
|
|
|
|
struct T<'a> {
|
2019-05-28 18:47:21 +00:00
|
|
|
t: [&'a (dyn Foo+'a); 2]
|
2014-06-21 04:16:14 +00:00
|
|
|
}
|
|
|
|
let _n = T {
|
2015-01-25 21:05:03 +00:00
|
|
|
t: [&1, &2]
|
2014-06-21 04:16:14 +00:00
|
|
|
};
|
2015-01-25 21:05:03 +00:00
|
|
|
let r = &1;
|
2014-06-21 04:16:14 +00:00
|
|
|
let _n = T {
|
2014-12-20 02:20:51 +00:00
|
|
|
t: [r; 2]
|
2014-06-21 04:16:14 +00:00
|
|
|
};
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: [&dyn Foo; 2] = [&1, &2];
|
2014-06-21 04:16:14 +00:00
|
|
|
let _n = T {
|
|
|
|
t: x
|
|
|
|
};
|
|
|
|
|
|
|
|
struct F<'b> {
|
2019-05-28 18:47:21 +00:00
|
|
|
t: &'b [&'b (dyn Foo+'b)]
|
2014-06-21 04:16:14 +00:00
|
|
|
}
|
|
|
|
let _n = F {
|
2015-01-25 21:05:03 +00:00
|
|
|
t: &[&1, &2]
|
2014-06-21 04:16:14 +00:00
|
|
|
};
|
2015-01-25 21:05:03 +00:00
|
|
|
let r = &1;
|
2019-05-28 18:47:21 +00:00
|
|
|
let r: [&dyn Foo; 2] = [r; 2];
|
2014-06-21 04:16:14 +00:00
|
|
|
let _n = F {
|
2014-11-17 08:39:01 +00:00
|
|
|
t: &r
|
2014-06-21 04:16:14 +00:00
|
|
|
};
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: [&dyn Foo; 2] = [&1, &2];
|
2014-06-21 04:16:14 +00:00
|
|
|
let _n = F {
|
2014-11-17 08:39:01 +00:00
|
|
|
t: &x
|
2014-06-21 04:16:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct M<'a> {
|
2019-05-28 18:47:21 +00:00
|
|
|
t: &'a [Box<dyn Foo+'static>]
|
2014-06-21 04:16:14 +00:00
|
|
|
}
|
|
|
|
let _n = M {
|
2015-02-15 08:52:21 +00:00
|
|
|
t: &[Box::new(1), Box::new(2)]
|
2014-06-21 04:16:14 +00:00
|
|
|
};
|
2019-05-28 18:47:21 +00:00
|
|
|
let x: [Box<dyn Foo>; 2] = [Box::new(1), Box::new(2)];
|
2014-06-21 04:16:14 +00:00
|
|
|
let _n = M {
|
2014-11-17 08:39:01 +00:00
|
|
|
t: &x
|
2014-06-21 04:16:14 +00:00
|
|
|
};
|
|
|
|
}
|