]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/where-clause-vs-impl.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / where-clause-vs-impl.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4 // Test that when there is a conditional (but blanket) impl and a
5 // where clause, we don't get confused in trait resolution.
6 //
7 // Issue #18453.
8
9 // pretty-expanded FIXME #23616
10
11 use std::rc::Rc;
12
13 pub trait Foo<M> {
14     fn foo(&mut self, msg: M);
15 }
16
17 pub trait Bar<M> {
18     fn dummy(&self) -> M;
19 }
20
21 impl<M, F: Bar<M>> Foo<M> for F {
22     fn foo(&mut self, msg: M) {
23     }
24 }
25
26 pub struct Both<M, F> {
27     inner: Rc<(M, F)>,
28 }
29
30 impl<M, F: Foo<M>> Clone for Both<M, F> {
31     fn clone(&self) -> Both<M, F> {
32         Both { inner: self.inner.clone() }
33     }
34 }
35
36 fn repro1<M, F: Foo<M>>(_both: Both<M, F>) {
37 }
38
39 fn repro2<M, F: Foo<M>>(msg: M, foo: F) {
40     let both = Both { inner: Rc::new((msg, foo)) };
41     repro1(both.clone()); // <--- This clone causes problem
42 }
43
44 pub fn main() {
45 }