summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-issue-22246.rs
blob: 0858833678bfa647ce2481db4a640dd5dac48787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// run-pass
#![allow(unused_imports)]
// Regression test for issue #22246 -- we should be able to deduce
// that `&'a B::Owned` implies that `B::Owned : 'a`.

// pretty-expanded FIXME #23616

#![allow(dead_code)]

use std::ops::Deref;

pub trait ToOwned: Sized {
    type Owned: Borrow<Self>;
    fn to_owned(&self) -> Self::Owned;
}

pub trait Borrow<Borrowed> {
    fn borrow(&self) -> &Borrowed;
}

pub struct Foo<B:ToOwned> {
    owned: B::Owned
}

fn foo<B:ToOwned>(this: &Foo<B>) -> &B {
    this.owned.borrow()
}

fn main() { }