]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/region-object-lifetime-in-coercion.stderr
Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr
[rust.git] / src / test / ui / regions / region-object-lifetime-in-coercion.stderr
1 error: lifetime may not live long enough
2   --> $DIR/region-object-lifetime-in-coercion.rs:8:12
3    |
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`
8    |
9 help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
10    |
11 LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
12    |                                 ~~
13 help: alternatively, add an explicit `'static` bound to this reference
14    |
15 LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> {
16    |         ~~~~~~~~~~~~~
17
18 error: lifetime may not live long enough
19   --> $DIR/region-object-lifetime-in-coercion.rs:14:5
20    |
21 LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
22    |         - let's call the lifetime of this reference `'1`
23 LL |     Box::new(v)
24    |     ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
25    |
26 help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
27    |
28 LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
29    |                                 ~~
30 help: alternatively, add an explicit `'static` bound to this reference
31    |
32 LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> {
33    |         ~~~~~~~~~~~~~
34
35 error: lifetime may not live long enough
36   --> $DIR/region-object-lifetime-in-coercion.rs:21:5
37    |
38 LL | fn c(v: &[u8]) -> Box<dyn Foo> {
39    |         - let's call the lifetime of this reference `'1`
40 ...
41 LL |     Box::new(v)
42    |     ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
43    |
44 help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound
45    |
46 LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
47    |                               ++++
48
49 error: lifetime may not live long enough
50   --> $DIR/region-object-lifetime-in-coercion.rs:26:5
51    |
52 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
53    |      -- -- lifetime `'b` defined here
54    |      |
55    |      lifetime `'a` defined here
56 LL |     Box::new(v)
57    |     ^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
58    |
59    = help: consider adding the following bound: `'a: 'b`
60
61 error: aborting due to 4 previous errors
62