1 error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
2 --> $DIR/region-object-lifetime-in-coercion.rs:8:46
4 LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
5 | ----- this data with an anonymous lifetime `'_`...
6 LL | let x: Box<dyn Foo + 'static> = Box::new(v);
7 | ^ ...is captured here, requiring it to live as long as `'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[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
19 --> $DIR/region-object-lifetime-in-coercion.rs:13:14
21 LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
22 | ----- this data with an anonymous lifetime `'_`...
24 | ^ ...is captured here, requiring it to live as long as `'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[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
36 --> $DIR/region-object-lifetime-in-coercion.rs:19:14
38 LL | fn c(v: &[u8]) -> Box<dyn Foo> {
39 | ----- this data with an anonymous lifetime `'_`...
42 | ^ ...is captured here, requiring it to live as long as `'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[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
50 --> $DIR/region-object-lifetime-in-coercion.rs:23:14
55 note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 22:6...
56 --> $DIR/region-object-lifetime-in-coercion.rs:22:6
58 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
60 note: ...so that the expression is assignable
61 --> $DIR/region-object-lifetime-in-coercion.rs:23:14
65 = note: expected `&[u8]`
67 note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 22:9...
68 --> $DIR/region-object-lifetime-in-coercion.rs:22:9
70 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
72 note: ...so that the expression is assignable
73 --> $DIR/region-object-lifetime-in-coercion.rs:23:5
77 = note: expected `Box<(dyn Foo + 'b)>`
80 error: aborting due to 4 previous errors
82 Some errors have detailed explanations: E0495, E0759.
83 For more information about an error, try `rustc --explain E0495`.