]> git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-trait-object-subtyping.rs
Update upstream source from tag 'upstream/1.37.0+dfsg1'
[rustc.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 //~ ERROR lifetime bound not satisfied
16 //~^ ERROR cannot infer an appropriate lifetime
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 //~ ERROR mismatched types
23 }
24
25 fn main() {}