// Test that attempts to implicitly coerce a value into an
// object respect the lifetime bound on the object type.
-#![feature(box_syntax)]
-
-trait Foo : ::std::marker::MarkerTrait {}
+trait Foo {}
impl<'a> Foo for &'a [u8] {}
fn a(v: &[u8]) -> Box<Foo + 'static> {
- let x: Box<Foo + 'static> = box v; //~ ERROR does not fulfill the required lifetime
+ let x: Box<Foo + 'static> = Box::new(v);
+ //~^ ERROR cannot infer an appropriate lifetime due to conflicting
x
}
fn b(v: &[u8]) -> Box<Foo + 'static> {
- box v //~ ERROR does not fulfill the required lifetime
+ Box::new(v)
+ //~^ ERROR cannot infer an appropriate lifetime due to conflicting
}
fn c(v: &[u8]) -> Box<Foo> {
// same as previous case due to RFC 599
- box v //~ ERROR does not fulfill the required lifetime
+ Box::new(v)
+ //~^ ERROR cannot infer an appropriate lifetime due to conflicting
}
fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> {
- box v //~ ERROR does not fulfill the required lifetime
+ Box::new(v)
+ //~^ ERROR cannot infer an appropriate lifetime due to conflicting
}
fn e<'a:'b,'b>(v: &'a [u8]) -> Box<Foo+'b> {
- box v // OK, thanks to 'a:'b
+ Box::new(v) // OK, thanks to 'a:'b
}
fn main() { }