2024-02-16 20:02:50 +00:00
|
|
|
//@ check-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(dead_code)]
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ pretty-expanded FIXME #23616
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2015-01-06 10:16:49 +13:00
|
|
|
pub trait Borrow<Borrowed: ?Sized> {
|
2014-12-24 12:05:57 -08: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 10:29:52 -05:00
|
|
|
struct MyTree<K>(K);
|
2014-12-24 12:05:57 -08: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() {}
|