]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/region-object-lifetime-in-coercion.rs
1 // Test that attempts to implicitly coerce a value into an
2 // object respect the lifetime bound on the object type.
5 impl<'a
> Foo
for &'a
[u8] {}
7 fn a(v
: &[u8]) -> Box
<dyn Foo
+ '
static> {
8 let x
: Box
<dyn Foo
+ '
static> = Box
::new(v
);
9 //~^ ERROR lifetime may not live long enough
13 fn b(v
: &[u8]) -> Box
<dyn Foo
+ '
static> {
15 //~^ ERROR lifetime may not live long enough
18 fn c(v
: &[u8]) -> Box
<dyn Foo
> {
19 // same as previous case due to RFC 599
22 //~^ ERROR lifetime may not live long enough
25 fn d
<'a
,'b
>(v
: &'a
[u8]) -> Box
<dyn Foo
+'b
> {
27 //~^ ERROR lifetime may not live long enough
30 fn e
<'a
:'b
,'b
>(v
: &'a
[u8]) -> Box
<dyn Foo
+'b
> {
31 Box
::new(v
) // OK, thanks to 'a:'b