2015-03-19 06:16:40 -05:00
|
|
|
trait Dummy { fn dummy(&self); }
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn foo1<'a:'b,'b>(x: &'a mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) {
|
2015-03-19 06:16:40 -05:00
|
|
|
// Here, we are able to coerce
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn foo2<'a:'b,'b>(x: &'b mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) {
|
2015-03-19 06:16:40 -05:00
|
|
|
// Here, we are able to coerce
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy {
|
2015-03-19 06:16:40 -05:00
|
|
|
// Without knowing 'a:'b, we can't coerce
|
2017-05-02 20:25:15 -05:00
|
|
|
x //~ ERROR lifetime bound not satisfied
|
2017-03-08 21:54:52 -06:00
|
|
|
//~^ ERROR cannot infer an appropriate lifetime
|
2015-03-19 06:16:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Wrapper<T>(T);
|
2019-05-28 13:46:13 -05:00
|
|
|
fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> {
|
2015-03-19 06:16:40 -05:00
|
|
|
// We can't coerce because it is packed in `Wrapper`
|
|
|
|
x //~ ERROR mismatched types
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|