rust/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
520 B
Rust
Raw Normal View History

2020-11-22 08:51:05 -06:00
//! Basic test for calling methods on generic type parameters in `const fn`.
2023-04-16 06:12:37 -05:00
// known-bug: #110395
2020-11-22 08:51:05 -06:00
#![feature(const_trait_impl)]
struct S;
impl const PartialEq for S {
fn eq(&self, _: &S) -> bool {
true
}
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() {}