Skip to content

Commit

Permalink
Add a test case for issue 18906
Browse files Browse the repository at this point in the history
Closes issue rust-lang#18906
  • Loading branch information
jroesch committed Dec 26, 2014
1 parent 29ad853 commit d25357c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/test/run-pass/issue-18906.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub trait Borrow<Sized? Borrowed> {
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())
}

struct MyTree<K>;

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() {}

2 comments on commit d25357c

@alexcrichton
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

@luqmana
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors: rollup

Please sign in to comment.