fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
2.3 KiB62 linesraw
1error: lifetime may not live long enough
2  --> $DIR/region-object-lifetime-in-coercion.rs:8:12
3   |
4LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
5   |         - let's call the lifetime of this reference `'1`
6LL |     let x: Box<dyn Foo + 'static> = Box::new(v);
7   |            ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
8   |
9help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
10   |
11LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
12   |                                 ~~
13help: alternatively, add an explicit `'static` bound to this reference
14   |
15LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> {
16   |         ~~~~~~~~~~~~~
17
18error: lifetime may not live long enough
19  --> $DIR/region-object-lifetime-in-coercion.rs:14:5
20   |
21LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
22   |         - let's call the lifetime of this reference `'1`
23LL |     Box::new(v)
24   |     ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
25   |
26help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
27   |
28LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
29   |                                 ~~
30help: alternatively, add an explicit `'static` bound to this reference
31   |
32LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> {
33   |         ~~~~~~~~~~~~~
34
35error: lifetime may not live long enough
36  --> $DIR/region-object-lifetime-in-coercion.rs:21:5
37   |
38LL | fn c(v: &[u8]) -> Box<dyn Foo> {
39   |         - let's call the lifetime of this reference `'1`
40...
41LL |     Box::new(v)
42   |     ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
43   |
44help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound
45   |
46LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
47   |                               ++++
48
49error: lifetime may not live long enough
50  --> $DIR/region-object-lifetime-in-coercion.rs:26:5
51   |
52LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
53   |      -- -- lifetime `'b` defined here
54   |      |
55   |      lifetime `'a` defined here
56LL |     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
61error: aborting due to 4 previous errors
62