]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/trait-where-clause-vs-impl.rs
rustdoc: Replace no-pretty-expanded with pretty-expanded
[rust.git] / src / test / run-pass / trait-where-clause-vs-impl.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Test that when there is a conditional (but blanket) impl and a
12 // where clause, we don't get confused in trait resolution.
13 //
14 // Issue #18453.
15
16 // pretty-expanded FIXME #23616
17
18 use std::rc::Rc;
19
20 pub trait Foo<M> {
21     fn foo(&mut self, msg: M);
22 }
23
24 pub trait Bar<M> {
25     fn dummy(&self) -> M;
26 }
27
28 impl<M, F: Bar<M>> Foo<M> for F {
29     fn foo(&mut self, msg: M) {
30     }
31 }
32
33 pub struct Both<M, F> {
34     inner: Rc<(M, F)>,
35 }
36
37 impl<M, F: Foo<M>> Clone for Both<M, F> {
38     fn clone(&self) -> Both<M, F> {
39         Both { inner: self.inner.clone() }
40     }
41 }
42
43 fn repro1<M, F: Foo<M>>(_both: Both<M, F>) {
44 }
45
46 fn repro2<M, F: Foo<M>>(msg: M, foo: F) {
47     let both = Both { inner: Rc::new((msg, foo)) };
48     repro1(both.clone()); // <--- This clone causes problem
49 }
50
51 pub fn main() {
52 }