summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/region-object-lifetime-in-coercion.stderr
blob: b5bb08c73c890f3dbda737fb12c3b20f1140ffc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
error: lifetime may not live long enough
  --> $DIR/region-object-lifetime-in-coercion.rs:8:12
   |
LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
   |         - let's call the lifetime of this reference `'1`
LL |     let x: Box<dyn Foo + 'static> = Box::new(v);
   |            ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
   |
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> {
   |         ~~~~~~~~~~~~~

error: lifetime may not live long enough
  --> $DIR/region-object-lifetime-in-coercion.rs:14:5
   |
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
   |         - let's call the lifetime of this reference `'1`
LL |     Box::new(v)
   |     ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
   |
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> {
   |         ~~~~~~~~~~~~~

error: lifetime may not live long enough
  --> $DIR/region-object-lifetime-in-coercion.rs:21:5
   |
LL | fn c(v: &[u8]) -> Box<dyn Foo> {
   |         - let's call the lifetime of this reference `'1`
...
LL |     Box::new(v)
   |     ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
   |
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 + '_> {
   |                               ++++

error: lifetime may not live long enough
  --> $DIR/region-object-lifetime-in-coercion.rs:26:5
   |
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
   |      -- -- lifetime `'b` defined here
   |      |
   |      lifetime `'a` defined here
LL |     Box::new(v)
   |     ^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
   |
   = help: consider adding the following bound: `'a: 'b`

error: aborting due to 4 previous errors