From d25357c5220c47feb31d86515ed823b14d98909f Mon Sep 17 00:00:00 2001 From: Jared Roesch Date: Wed, 24 Dec 2014 12:05:57 -0800 Subject: [PATCH] Add a test case for issue 18906 Closes issue #18906 --- src/test/run-pass/issue-18906.rs | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/test/run-pass/issue-18906.rs diff --git a/src/test/run-pass/issue-18906.rs b/src/test/run-pass/issue-18906.rs new file mode 100644 index 00000000000..e82359bc168 --- /dev/null +++ b/src/test/run-pass/issue-18906.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Borrow { + fn borrow(&self) -> &Borrowed; +} + +impl Borrow for T { + fn borrow(&self) -> &T { self } +} + +trait Foo { + fn foo(&self, other: &Self); +} + +fn bar(k: &K, q: &Q) where K: Borrow, Q: Foo { + q.foo(k.borrow()) +} + +struct MyTree; + +impl MyTree { + // This caused a failure in #18906 + fn bar(k: &K, q: &Q) where K: Borrow, Q: Foo { + q.foo(k.borrow()) + } +} + +fn main() {}