2 // ignore-compare-mode-nll
3 //[nll] compile-flags: -Z borrowck=mir
5 trait Dummy { fn dummy(&self); }
7 fn foo1
<'a
:'b
,'b
>(x
: &'a
mut (dyn Dummy
+'a
)) -> &'b
mut (dyn Dummy
+'b
) {
8 // Here, we are able to coerce
12 fn foo2
<'a
:'b
,'b
>(x
: &'b
mut (dyn Dummy
+'a
)) -> &'b
mut (dyn Dummy
+'b
) {
13 // Here, we are able to coerce
17 fn foo3
<'a
,'b
>(x
: &'a
mut dyn Dummy
) -> &'b
mut dyn Dummy
{
18 // Without knowing 'a:'b, we can't coerce
20 //[base]~^ ERROR lifetime bound not satisfied
21 //[base]~| ERROR cannot infer an appropriate lifetime
22 //[nll]~^^^ ERROR lifetime may not live long enough
26 fn foo4
<'a
:'b
,'b
>(x
: Wrapper
<&'a
mut dyn Dummy
>) -> Wrapper
<&'b
mut dyn Dummy
> {
27 // We can't coerce because it is packed in `Wrapper`
29 //[base]~^ ERROR mismatched types
30 //[nll]~^^ ERROR lifetime may not live long enough