2020-05-29 20:05:20 -05:00
|
|
|
error: lifetime may not live long enough
|
2022-04-01 12:13:25 -05:00
|
|
|
--> $DIR/region-object-lifetime-in-coercion.rs:8:12
|
2019-01-27 05:03:21 -06:00
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
|
2020-05-29 20:05:20 -05:00
|
|
|
| - let's call the lifetime of this reference `'1`
|
2019-05-28 13:46:13 -05:00
|
|
|
LL | let x: Box<dyn Foo + 'static> = Box::new(v);
|
2020-05-29 20:05:20 -05:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
|
2022-04-24 09:44:09 -05:00
|
|
|
|
|
|
|
|
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
|
|
|
|
|
|
|
|
LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
|
|
|
|
| ~~
|
|
|
|
help: alternatively, add an explicit `'static` bound to this reference
|
|
|
|
|
|
|
|
|
LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
|
|
|
| ~~~~~~~~~~~~~
|
2019-01-27 05:03:21 -06:00
|
|
|
|
2020-05-29 20:05:20 -05:00
|
|
|
error: lifetime may not live long enough
|
2022-04-01 12:13:25 -05:00
|
|
|
--> $DIR/region-object-lifetime-in-coercion.rs:14:5
|
2019-01-27 05:03:21 -06:00
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
2020-05-29 20:05:20 -05:00
|
|
|
| - let's call the lifetime of this reference `'1`
|
2019-01-27 05:03:21 -06:00
|
|
|
LL | Box::new(v)
|
2020-05-29 20:05:20 -05:00
|
|
|
| ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
2022-04-24 09:44:09 -05:00
|
|
|
|
|
|
|
|
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
|
|
|
|
|
|
|
|
LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
|
|
|
|
| ~~
|
|
|
|
help: alternatively, add an explicit `'static` bound to this reference
|
|
|
|
|
|
|
|
|
LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
|
|
|
| ~~~~~~~~~~~~~
|
2019-01-27 05:03:21 -06:00
|
|
|
|
2020-05-26 19:22:47 -05:00
|
|
|
error: lifetime may not live long enough
|
2022-04-01 12:13:25 -05:00
|
|
|
--> $DIR/region-object-lifetime-in-coercion.rs:21:5
|
2019-01-27 05:03:21 -06:00
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
LL | fn c(v: &[u8]) -> Box<dyn Foo> {
|
2020-05-26 19:22:47 -05:00
|
|
|
| - let's call the lifetime of this reference `'1`
|
2019-01-27 05:03:21 -06:00
|
|
|
...
|
|
|
|
LL | Box::new(v)
|
2020-05-26 19:22:47 -05:00
|
|
|
| ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
2022-04-24 09:44:09 -05:00
|
|
|
|
|
|
|
|
help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound
|
|
|
|
|
|
|
|
|
LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
|
|
|
|
| ++++
|
2019-01-27 05:03:21 -06:00
|
|
|
|
|
|
|
error: lifetime may not live long enough
|
2022-04-01 12:13:25 -05:00
|
|
|
--> $DIR/region-object-lifetime-in-coercion.rs:26:5
|
2019-01-27 05:03:21 -06:00
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
2019-01-27 05:03:21 -06:00
|
|
|
| -- -- lifetime `'b` defined here
|
|
|
|
| |
|
|
|
|
| lifetime `'a` defined here
|
|
|
|
LL | Box::new(v)
|
2021-12-31 15:55:34 -06:00
|
|
|
| ^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
|
2019-10-27 09:39:14 -05:00
|
|
|
|
|
|
|
|
= help: consider adding the following bound: `'a: 'b`
|
2019-01-27 05:03:21 -06:00
|
|
|
|
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
|