error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:8:37 | LL | fn a(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` LL | let x: Box = Box::new(v); | ^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:14:5 | LL | fn b(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` LL | Box::new(v) | ^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:21:5 | LL | fn c(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` ... LL | Box::new(v) | ^^^^^^^^^^^ lifetime `'static` required error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> $DIR/region-object-lifetime-in-coercion.rs:26:14 | LL | Box::new(v) | ^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 25:6... --> $DIR/region-object-lifetime-in-coercion.rs:25:6 | LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | ^^ note: ...so that the expression is assignable --> $DIR/region-object-lifetime-in-coercion.rs:26:14 | LL | Box::new(v) | ^ = note: expected `&[u8]` found `&'a [u8]` note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 25:9... --> $DIR/region-object-lifetime-in-coercion.rs:25:9 | LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | ^^ note: ...so that the expression is assignable --> $DIR/region-object-lifetime-in-coercion.rs:26:5 | LL | Box::new(v) | ^^^^^^^^^^^ = note: expected `std::boxed::Box<(dyn Foo + 'b)>` found `std::boxed::Box` error: aborting due to 4 previous errors Some errors have detailed explanations: E0495, E0621. For more information about an error, try `rustc --explain E0495`.