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