2019-11-04 00:00:00 +00:00
|
|
|
// check-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-01-05 21:16:49 +00:00
|
|
|
pub trait Borrow<Borrowed: ?Sized> {
|
2014-12-24 20:05:57 +00:00
|
|
|
fn borrow(&self) -> &Borrowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: Sized> Borrow<T> for T {
|
|
|
|
fn borrow(&self) -> &T { self }
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Foo {
|
|
|
|
fn foo(&self, other: &Self);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bar<K, Q>(k: &K, q: &Q) where K: Borrow<Q>, Q: Foo {
|
|
|
|
q.foo(k.borrow())
|
|
|
|
}
|
|
|
|
|
2015-02-12 15:29:52 +00:00
|
|
|
struct MyTree<K>(K);
|
2014-12-24 20:05:57 +00:00
|
|
|
|
|
|
|
impl<K> MyTree<K> {
|
|
|
|
// This caused a failure in #18906
|
|
|
|
fn bar<Q>(k: &K, q: &Q) where K: Borrow<Q>, Q: Foo {
|
|
|
|
q.foo(k.borrow())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|