blob: 8209fa1840d05d12611aacf30e80edc54c27d419 [file] [log] [blame]
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<dyn Foo + 'static> {
| ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]`
LL | let x: Box<dyn Foo + 'static> = 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<dyn Foo + 'static> {
| ----- 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<dyn Foo> {
| ----- 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<dyn Foo+'b> {
| ^^
= note: ...so that the expression is assignable:
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<dyn Foo+'b> {
| ^^
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn Foo + 'b)>
found std::boxed::Box<dyn Foo>
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0621`.