2020-11-22 08:51:05 -06:00
|
|
|
// check-pass
|
|
|
|
|
|
|
|
#![feature(const_trait_impl)]
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
impl const PartialEq for S {
|
|
|
|
fn eq(&self, _: &S) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2021-06-23 05:37:26 -05:00
|
|
|
fn ne(&self, other: &S) -> bool {
|
|
|
|
!self.eq(other)
|
|
|
|
}
|
2020-11-22 08:51:05 -06:00
|
|
|
}
|
|
|
|
|
2021-08-25 09:30:09 -05:00
|
|
|
// This duplicate bound should not result in ambiguities. It should be equivalent to a single ~const
|
2020-11-22 08:51:05 -06:00
|
|
|
// bound.
|
2021-09-11 04:40:19 -05:00
|
|
|
const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
|
2020-11-22 08:51:05 -06:00
|
|
|
*t == *t
|
|
|
|
}
|
|
|
|
|
2021-09-11 04:40:19 -05:00
|
|
|
trait A: PartialEq {}
|
|
|
|
impl<T: PartialEq> A for T {}
|
|
|
|
|
|
|
|
const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
|
|
|
|
*t == *t
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const EQ: bool = equals_self(&S) && equals_self2(&S);
|
2020-11-22 08:51:05 -06:00
|
|
|
|
|
|
|
fn main() {}
|