]> git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/region-object-lifetime-in-coercion.stderr
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / regions / region-object-lifetime-in-coercion.stderr
1 error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
2 --> $DIR/region-object-lifetime-in-coercion.rs:8:46
3 |
4 LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
5 | ----- this data with an anonymous lifetime `'_`...
6 LL | let x: Box<dyn Foo + 'static> = Box::new(v);
7 | ^ ...is captured here, requiring it to live as long as `'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[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
19 --> $DIR/region-object-lifetime-in-coercion.rs:13:14
20 |
21 LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
22 | ----- this data with an anonymous lifetime `'_`...
23 LL | Box::new(v)
24 | ^ ...is captured here, requiring it to live as long as `'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[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
36 --> $DIR/region-object-lifetime-in-coercion.rs:19:14
37 |
38 LL | fn c(v: &[u8]) -> Box<dyn Foo> {
39 | ----- this data with an anonymous lifetime `'_`...
40 ...
41 LL | Box::new(v)
42 | ^ ...is captured here, requiring it to live as long as `'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[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
50 --> $DIR/region-object-lifetime-in-coercion.rs:23:14
51 |
52 LL | Box::new(v)
53 | ^
54 |
55 note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 22:6...
56 --> $DIR/region-object-lifetime-in-coercion.rs:22:6
57 |
58 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
59 | ^^
60 note: ...so that the expression is assignable
61 --> $DIR/region-object-lifetime-in-coercion.rs:23:14
62 |
63 LL | Box::new(v)
64 | ^
65 = note: expected `&[u8]`
66 found `&'a [u8]`
67 note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 22:9...
68 --> $DIR/region-object-lifetime-in-coercion.rs:22:9
69 |
70 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
71 | ^^
72 note: ...so that the expression is assignable
73 --> $DIR/region-object-lifetime-in-coercion.rs:23:5
74 |
75 LL | Box::new(v)
76 | ^^^^^^^^^^^
77 = note: expected `Box<(dyn Foo + 'b)>`
78 found `Box<dyn Foo>`
79
80 error: aborting due to 4 previous errors
81
82 Some errors have detailed explanations: E0495, E0759.
83 For more information about an error, try `rustc --explain E0495`.