rust/tests/ui/issues/issue-11205.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
1.6 KiB
Rust
Raw Normal View History

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