diff options
Diffstat (limited to 'src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr')
| -rw-r--r-- | src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr index 92588819076..724b06ce8b1 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr @@ -1,30 +1,53 @@ error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:8:12 + --> $DIR/region-object-lifetime-in-coercion.rs:12: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:13:5 + --> $DIR/region-object-lifetime-in-coercion.rs:19: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:19:5 + --> $DIR/region-object-lifetime-in-coercion.rs:27: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:23:5 + --> $DIR/region-object-lifetime-in-coercion.rs:33:5 | LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> { | -- -- lifetime `'b` defined here |
