]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs
Fix duplicate bounds for const_trait_impl
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / call-generic-method-dup-bound.rs
1 // check-pass
2
3 #![feature(const_trait_impl)]
4 #![feature(const_fn_trait_bound)]
5
6 struct S;
7
8 impl const PartialEq for S {
9     fn eq(&self, _: &S) -> bool {
10         true
11     }
12     fn ne(&self, other: &S) -> bool {
13         !self.eq(other)
14     }
15 }
16
17 // This duplicate bound should not result in ambiguities. It should be equivalent to a single ~const
18 // bound.
19 const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
20     *t == *t
21 }
22
23 trait A: PartialEq {}
24 impl<T: PartialEq> A for T {}
25
26 const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
27     *t == *t
28 }
29
30 pub const EQ: bool = equals_self(&S) && equals_self2(&S);
31
32 fn main() {}