1 // Test that attempts to implicitly coerce a value into an
2 // object respect the lifetime bound on the object type.
5 impl<'a> Foo for &'a [u8] {}
7 fn a(v: &[u8]) -> Box<Foo + 'static> {
8 let x: Box<Foo + 'static> = Box::new(v);
9 //~^ ERROR explicit lifetime required in the type of `v` [E0621]
13 fn b(v: &[u8]) -> Box<Foo + 'static> {
15 //~^ ERROR explicit lifetime required in the type of `v` [E0621]
18 fn c(v: &[u8]) -> Box<Foo> {
19 // same as previous case due to RFC 599
22 //~^ ERROR explicit lifetime required in the type of `v` [E0621]
25 fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> {
27 //~^ ERROR cannot infer an appropriate lifetime due to conflicting
30 fn e<'a:'b,'b>(v: &'a [u8]) -> Box<Foo+'b> {
31 Box::new(v) // OK, thanks to 'a:'b