]> git.proxmox.com Git - rustc.git/blame - src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / regions / region-object-lifetime-in-coercion.nll.stderr
CommitLineData
f035d41b 1error: lifetime may not live long enough
04454e1e 2 --> $DIR/region-object-lifetime-in-coercion.rs:12:12
48663c56 3 |
dc9dc135 4LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
f035d41b 5 | - let's call the lifetime of this reference `'1`
dc9dc135 6LL | let x: Box<dyn Foo + 'static> = Box::new(v);
f035d41b 7 | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
04454e1e
FG
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 | ~~~~~~~~~~~~~
48663c56 17
f035d41b 18error: lifetime may not live long enough
04454e1e 19 --> $DIR/region-object-lifetime-in-coercion.rs:19:5
48663c56 20 |
dc9dc135 21LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
f035d41b 22 | - let's call the lifetime of this reference `'1`
48663c56 23LL | Box::new(v)
f035d41b 24 | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
04454e1e
FG
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 | ~~~~~~~~~~~~~
48663c56 34
f9f354fc 35error: lifetime may not live long enough
04454e1e 36 --> $DIR/region-object-lifetime-in-coercion.rs:27:5
48663c56 37 |
dc9dc135 38LL | fn c(v: &[u8]) -> Box<dyn Foo> {
f9f354fc 39 | - let's call the lifetime of this reference `'1`
48663c56
XL
40...
41LL | Box::new(v)
f9f354fc 42 | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
04454e1e
FG
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 | ++++
48663c56
XL
48
49error: lifetime may not live long enough
04454e1e 50 --> $DIR/region-object-lifetime-in-coercion.rs:33:5
48663c56 51 |
dc9dc135 52LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
48663c56
XL
53 | -- -- lifetime `'b` defined here
54 | |
55 | lifetime `'a` defined here
56LL | Box::new(v)
5099ac24 57 | ^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
60c5eb7d
XL
58 |
59 = help: consider adding the following bound: `'a: 'b`
48663c56
XL
60
61error: aborting due to 4 previous errors
62