]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-trait-object-subtyping.rs
Rollup merge of #106043 - c410-f3r:moar-errors, r=petrochenkov
[rust.git] / src / test / ui / regions / regions-trait-object-subtyping.rs
1 trait Dummy { fn dummy(&self); }
2
3 fn foo1<'a:'b,'b>(x: &'a mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) {
4     // Here, we are able to coerce
5     x
6 }
7
8 fn foo2<'a:'b,'b>(x: &'b mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) {
9     // Here, we are able to coerce
10     x
11 }
12
13 fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy {
14     // Without knowing 'a:'b, we can't coerce
15     x
16     //~^ ERROR lifetime may not live long enough
17 }
18
19 struct Wrapper<T>(T);
20 fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> {
21     // We can't coerce because it is packed in `Wrapper`
22     x
23     //~^ ERROR lifetime may not live long enough
24 }
25
26 fn main() {}