Jonas Schievink | e69fcea | 2020-11-22 03:19:46 | [diff] [blame] | 1 | //! Basic test for calling methods on generic type parameters in `const fn`. |
2 | |||||
Deadbeef | 4c6ddc0 | 2023-04-16 11:12:37 | [diff] [blame] | 3 | // known-bug: #110395 |
Jonas Schievink | e69fcea | 2020-11-22 03:19:46 | [diff] [blame] | 4 | |
Jonas Schievink | e69fcea | 2020-11-22 03:19:46 | [diff] [blame] | 5 | #![feature(const_trait_impl)] |
Jonas Schievink | e69fcea | 2020-11-22 03:19:46 | [diff] [blame] | 6 | |
7 | struct S; | ||||
8 | |||||
9 | impl const PartialEq for S { | ||||
10 | fn eq(&self, _: &S) -> bool { | ||||
11 | true | ||||
12 | } | ||||
Deadbeef | 22a8d46 | 2021-06-23 10:37:26 | [diff] [blame] | 13 | fn ne(&self, other: &S) -> bool { |
14 | !self.eq(other) | ||||
15 | } | ||||
Jonas Schievink | e69fcea | 2020-11-22 03:19:46 | [diff] [blame] | 16 | } |
17 | |||||
Deadbeef | 703c557 | 2021-08-25 15:21:55 | [diff] [blame] | 18 | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { |
Jonas Schievink | e69fcea | 2020-11-22 03:19:46 | [diff] [blame] | 19 | *t == *t |
20 | } | ||||
21 | |||||
22 | pub const EQ: bool = equals_self(&S); | ||||
23 | |||||
24 | fn main() {} |