2020-11-22 08:51:05 -06:00
|
|
|
//! Basic test for calling methods on generic type parameters in `const fn`.
|
|
|
|
|
|
|
|
// 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 10:21:55 -05:00
|
|
|
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
|
2020-11-22 08:51:05 -06:00
|
|
|
*t == *t
|
|
|
|
}
|
|
|
|
|
2021-08-25 10:21:55 -05:00
|
|
|
const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
|
2020-11-22 08:51:05 -06:00
|
|
|
equals_self(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const EQ: bool = equals_self_wrapper(&S);
|
|
|
|
|
|
|
|
fn main() {}
|