2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(unused_imports)]
|
2015-02-13 19:52:55 -05:00
|
|
|
// Regression test for issue #22246 -- we should be able to deduce
|
|
|
|
// that `&'a B::Owned` implies that `B::Owned : 'a`.
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-02-13 19:52:55 -05:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
use std::ops::Deref;
|
|
|
|
|
2015-12-15 04:31:58 -05:00
|
|
|
pub trait ToOwned: Sized {
|
2015-02-13 19:52:55 -05:00
|
|
|
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() { }
|