]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-issue-22246.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-issue-22246.rs
1 // run-pass
2 #![allow(unused_imports)]
3 // Regression test for issue #22246 -- we should be able to deduce
4 // that `&'a B::Owned` implies that `B::Owned : 'a`.
5
6 // pretty-expanded FIXME #23616
7
8 #![allow(dead_code)]
9
10 use std::ops::Deref;
11
12 pub trait ToOwned: Sized {
13     type Owned: Borrow<Self>;
14     fn to_owned(&self) -> Self::Owned;
15 }
16
17 pub trait Borrow<Borrowed> {
18     fn borrow(&self) -> &Borrowed;
19 }
20
21 pub struct Foo<B:ToOwned> {
22     owned: B::Owned
23 }
24
25 fn foo<B:ToOwned>(this: &Foo<B>) -> &B {
26     this.owned.borrow()
27 }
28
29 fn main() { }