Skip to content

Commit 268d5f3

Browse files
committed
Restore const PartialEq
1 parent 2896841 commit 268d5f3

17 files changed

+52
-111
lines changed

library/core/src/cmp.rs

+12
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

+1-1
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

-8
This file was deleted.

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

+2-2
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

-14
This file was deleted.

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

+2-2
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

-14
This file was deleted.
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() {}
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

+2-2
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-pass.stderr

-8
This file was deleted.

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

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(
44
associated_type_bounds,
55
const_trait_impl,
6+
effects,
67
const_cmp,
78
)]
89

Original file line numberDiff line numberDiff line change
@@ -1,39 +1,16 @@
1-
error[E0635]: unknown feature `const_cmp`
2-
--> $DIR/const-impl-trait.rs:6:5
1+
error[E0277]: can't compare `impl PartialEq + Destruct + Copy` with `impl PartialEq + Destruct + Copy`
2+
--> $DIR/const-impl-trait.rs:28:17
33
|
4-
LL | const_cmp,
5-
| ^^^^^^^^^
6-
7-
error: ~const can only be applied to `#[const_trait]` traits
8-
--> $DIR/const-impl-trait.rs:11:30
9-
|
10-
LL | const fn cmp(a: &impl ~const PartialEq) -> bool {
11-
| ^^^^^^^^^
12-
13-
error: ~const can only be applied to `#[const_trait]` traits
14-
--> $DIR/const-impl-trait.rs:15:30
15-
|
16-
LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct)
17-
| ^^^^^^^^^
18-
19-
error: ~const can only be applied to `#[const_trait]` traits
20-
--> $DIR/const-impl-trait.rs:16:20
4+
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `impl PartialEq + Destruct + Copy == impl PartialEq + Destruct + Copy`
216
|
22-
LL | -> impl ~const PartialEq + ~const Destruct
23-
| ^^^^^^^^^
24-
25-
error: ~const can only be applied to `#[const_trait]` traits
26-
--> $DIR/const-impl-trait.rs:23:29
7+
= help: the trait `PartialEq<impl PartialEq + Destruct + Copy>` is not implemented for `impl PartialEq + Destruct + Copy`
8+
note: required by a bound in `Foo::{opaque#0}`
9+
--> $DIR/const-impl-trait.rs:24:22
2710
|
2811
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy;
29-
| ^^^^^^^^^
30-
31-
error: ~const can only be applied to `#[const_trait]` traits
32-
--> $DIR/const-impl-trait.rs:27:29
33-
|
34-
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
35-
| ^^^^^^^^^
12+
| ^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}`
3613

37-
error: aborting due to 6 previous errors
14+
error: aborting due to 1 previous error
3815

39-
For more information about this error, try `rustc --explain E0635`.
16+
For more information about this error, try `rustc --explain E0277`.

tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// known-bug: #110395
2-
#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
1+
// check-pass
2+
#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const, effects)]
33

44
pub struct A;
55

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
error[E0635]: unknown feature `const_cmp`
2-
--> $DIR/derive-const-use.rs:2:30
3-
|
4-
LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
5-
| ^^^^^^^^^
6-
71
error[E0635]: unknown feature `const_default_impls`
8-
--> $DIR/derive-const-use.rs:2:41
2+
--> $DIR/derive-const-use.rs:3:5
93
|
10-
LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
11-
| ^^^^^^^^^^^^^^^^^^^
4+
LL | const_default_impls, derive_const)]
5+
| ^^^^^^^^^^^^^^^^^^^
126

13-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
148

159
For more information about this error, try `rustc --explain E0635`.

tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// known-bug: #110395
1+
// check-pass
22

33
#![feature(derive_const)]
4-
#![feature(const_trait_impl)]
4+
#![feature(const_trait_impl, effects)]
55

66
#[derive_const(PartialEq)]
77
pub struct Reverse<T>(T);

tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr

-10
This file was deleted.

0 commit comments

Comments
 (0)