1 error: lifetime may not live long enough
2 --> $DIR/region-object-lifetime-in-coercion.rs:8:12
4 LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
5 | - let's call the lifetime of this reference `'1`
6 LL | let x: Box<dyn Foo + 'static> = Box::new(v);
7 | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
9 help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
11 LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
13 help: alternatively, add an explicit `'static` bound to this reference
15 LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> {
18 error: lifetime may not live long enough
19 --> $DIR/region-object-lifetime-in-coercion.rs:14:5
21 LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
22 | - let's call the lifetime of this reference `'1`
24 | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
26 help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
28 LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
30 help: alternatively, add an explicit `'static` bound to this reference
32 LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> {
35 error: lifetime may not live long enough
36 --> $DIR/region-object-lifetime-in-coercion.rs:21:5
38 LL | fn c(v: &[u8]) -> Box<dyn Foo> {
39 | - let's call the lifetime of this reference `'1`
42 | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
44 help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound
46 LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
49 error: lifetime may not live long enough
50 --> $DIR/region-object-lifetime-in-coercion.rs:26:5
52 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
53 | -- -- lifetime `'b` defined here
55 | lifetime `'a` defined here
57 | ^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
59 = help: consider adding the following bound: `'a: 'b`
61 error: aborting due to 4 previous errors