]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-close-object-into-object-2.stderr
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-close-object-into-object-2.stderr
1 error: lifetime may not live long enough
2   --> $DIR/regions-close-object-into-object-2.rs:9:5
3    |
4 LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
5    |      -- lifetime `'a` defined here
6 LL |     Box::new(B(&*v)) as Box<dyn X>
7    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
8    |
9 help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
10    |
11 LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> {
12    |                                                            ~~
13 help: alternatively, add an explicit `'static` bound to this reference
14    |
15 LL | fn g<'a, T: 'static>(v: Box<(dyn A<T> + 'static)>) -> Box<dyn X + 'static> {
16    |                         ~~~~~~~~~~~~~~~~~~~~~~~~~
17
18 error[E0515]: cannot return value referencing local data `*v`
19   --> $DIR/regions-close-object-into-object-2.rs:9:5
20    |
21 LL |     Box::new(B(&*v)) as Box<dyn X>
22    |     ^^^^^^^^^^^---^^^^^^^^^^^^^^^^
23    |     |          |
24    |     |          `*v` is borrowed here
25    |     returns a value referencing data owned by the current function
26
27 error: aborting due to 2 previous errors
28
29 For more information about this error, try `rustc --explain E0515`.