Skip to content

Commit d488730

Browse files
committed
Make PartialEq a const_trait
1 parent 0dbdf26 commit d488730

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

core/src/cmp.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ use crate::ops::ControlFlow;
247247
append_const_msg
248248
)]
249249
#[rustc_diagnostic_item = "PartialEq"]
250+
#[const_trait]
251+
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
250252
pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
251253
/// Tests for `self` and `other` values to be equal, and is used by `==`.
252254
#[must_use]
@@ -1811,7 +1813,8 @@ mod impls {
18111813
macro_rules! partial_eq_impl {
18121814
($($t:ty)*) => ($(
18131815
#[stable(feature = "rust1", since = "1.0.0")]
1814-
impl PartialEq for $t {
1816+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1817+
impl const PartialEq for $t {
18151818
#[inline]
18161819
fn eq(&self, other: &Self) -> bool { *self == *other }
18171820
#[inline]
@@ -2018,9 +2021,10 @@ mod impls {
20182021
// & pointers
20192022

20202023
#[stable(feature = "rust1", since = "1.0.0")]
2021-
impl<A: PointeeSized, B: PointeeSized> PartialEq<&B> for &A
2024+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
2025+
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &A
20222026
where
2023-
A: PartialEq<B>,
2027+
A: ~const PartialEq<B>,
20242028
{
20252029
#[inline]
20262030
fn eq(&self, other: &&B) -> bool {
@@ -2089,9 +2093,10 @@ mod impls {
20892093
// &mut pointers
20902094

20912095
#[stable(feature = "rust1", since = "1.0.0")]
2092-
impl<A: PointeeSized, B: PointeeSized> PartialEq<&mut B> for &mut A
2096+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
2097+
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&mut B> for &mut A
20932098
where
2094-
A: PartialEq<B>,
2099+
A: ~const PartialEq<B>,
20952100
{
20962101
#[inline]
20972102
fn eq(&self, other: &&mut B) -> bool {
@@ -2158,9 +2163,10 @@ mod impls {
21582163
impl<A: PointeeSized> Eq for &mut A where A: Eq {}
21592164

21602165
#[stable(feature = "rust1", since = "1.0.0")]
2161-
impl<A: PointeeSized, B: PointeeSized> PartialEq<&mut B> for &A
2166+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
2167+
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&mut B> for &A
21622168
where
2163-
A: PartialEq<B>,
2169+
A: ~const PartialEq<B>,
21642170
{
21652171
#[inline]
21662172
fn eq(&self, other: &&mut B) -> bool {
@@ -2173,9 +2179,10 @@ mod impls {
21732179
}
21742180

21752181
#[stable(feature = "rust1", since = "1.0.0")]
2176-
impl<A: PointeeSized, B: PointeeSized> PartialEq<&B> for &mut A
2182+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
2183+
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &mut A
21772184
where
2178-
A: PartialEq<B>,
2185+
A: ~const PartialEq<B>,
21792186
{
21802187
#[inline]
21812188
fn eq(&self, other: &&B) -> bool {

0 commit comments

Comments
 (0)