Skip to content

Commit f635cd2

Browse files
committed
Restore const PartialEq
1 parent 42dfac5 commit f635cd2

17 files changed

+52
-111
lines changed

library/core/src/cmp.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ use self::Ordering::*;
224224
append_const_msg
225225
)]
226226
#[rustc_diagnostic_item = "PartialEq"]
227+
#[cfg_attr(not(bootstrap), const_trait)]
227228
pub trait PartialEq<Rhs: ?Sized = Self> {
228229
/// This method tests for `self` and `other` values to be equal, and is used
229230
/// by `==`.
@@ -1414,12 +1415,23 @@ mod impls {
14141415
macro_rules! partial_eq_impl {
14151416
($($t:ty)*) => ($(
14161417
#[stable(feature = "rust1", since = "1.0.0")]
1418+
#[cfg(bootstrap)]
14171419
impl PartialEq for $t {
14181420
#[inline]
14191421
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
14201422
#[inline]
14211423
fn ne(&self, other: &$t) -> bool { (*self) != (*other) }
14221424
}
1425+
1426+
#[stable(feature = "rust1", since = "1.0.0")]
1427+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
1428+
#[cfg(not(bootstrap))]
1429+
impl const PartialEq for $t {
1430+
#[inline]
1431+
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
1432+
#[inline]
1433+
fn ne(&self, other: &$t) -> bool { (*self) != (*other) }
1434+
}
14231435
)*)
14241436
}
14251437

tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// known-bug: #110395
1+
// check-pass
22
#![feature(const_trait_impl)]
33

44
#[const_trait]

tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Basic test for calling methods on generic type parameters in `const fn`.
22
3-
// known-bug: #110395
3+
// check-pass
44

5-
#![feature(const_trait_impl)]
5+
#![feature(const_trait_impl, effects)]
66

77
struct S;
88

tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// known-bug: #110395
1+
// check-pass
22

3-
#![feature(const_trait_impl)]
3+
#![feature(const_trait_impl, effects)]
44

55
struct S;
66

tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// FIXME(effects)
2-
// check-pass
31
#![feature(const_trait_impl, effects)]
42

53
pub const fn equals_self<T: PartialEq>(t: &T) -> bool {
64
*t == *t
7-
// (remove this) ~^ ERROR can't compare
5+
//~^ ERROR mismatched types
6+
// FIXME(effects): diagnostic
87
}
98

109
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/call-generic-method-fail.rs:4:5
3+
|
4+
LL | *t == *t
5+
| ^^^^^^^^ expected `host`, found `true`
6+
|
7+
= note: expected constant `host`
8+
found constant `true`
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Basic test for calling methods on generic type parameters in `const fn`.
22
3-
// known-bug: #110395
3+
// check-pass
44

5-
#![feature(const_trait_impl)]
5+
#![feature(const_trait_impl, effects)]
66

77
struct S;
88

0 commit comments

Comments
 (0)