Restore const PartialEq
This commit is contained in:
parent
42dfac5e08
commit
f635cd2e82
@ -224,6 +224,7 @@ use self::Ordering::*;
|
||||
append_const_msg
|
||||
)]
|
||||
#[rustc_diagnostic_item = "PartialEq"]
|
||||
#[cfg_attr(not(bootstrap), const_trait)]
|
||||
pub trait PartialEq<Rhs: ?Sized = Self> {
|
||||
/// This method tests for `self` and `other` values to be equal, and is used
|
||||
/// by `==`.
|
||||
@ -1414,12 +1415,23 @@ mod impls {
|
||||
macro_rules! partial_eq_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[cfg(bootstrap)]
|
||||
impl PartialEq for $t {
|
||||
#[inline]
|
||||
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: &$t) -> bool { (*self) != (*other) }
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
|
||||
#[cfg(not(bootstrap))]
|
||||
impl const PartialEq for $t {
|
||||
#[inline]
|
||||
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: &$t) -> bool { (*self) != (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// known-bug: #110395
|
||||
// check-pass
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
#[const_trait]
|
||||
|
@ -1,8 +0,0 @@
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/call-generic-in-impl.rs:9:16
|
||||
|
|
||||
LL | impl<T: ~const PartialEq> const MyPartialEq for T {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
@ -1,8 +1,8 @@
|
||||
//! Basic test for calling methods on generic type parameters in `const fn`.
|
||||
|
||||
// known-bug: #110395
|
||||
// check-pass
|
||||
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_trait_impl, effects)]
|
||||
|
||||
struct S;
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/call-generic-method-chain.rs:18:32
|
||||
|
|
||||
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/call-generic-method-chain.rs:22:40
|
||||
|
|
||||
LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -1,6 +1,6 @@
|
||||
// known-bug: #110395
|
||||
// check-pass
|
||||
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_trait_impl, effects)]
|
||||
|
||||
struct S;
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/call-generic-method-dup-bound.rs:18:44
|
||||
|
|
||||
LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/call-generic-method-dup-bound.rs:25:37
|
||||
|
|
||||
LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -1,10 +1,9 @@
|
||||
// FIXME(effects)
|
||||
// check-pass
|
||||
#![feature(const_trait_impl, effects)]
|
||||
|
||||
pub const fn equals_self<T: PartialEq>(t: &T) -> bool {
|
||||
*t == *t
|
||||
// (remove this) ~^ ERROR can't compare
|
||||
//~^ ERROR mismatched types
|
||||
// FIXME(effects): diagnostic
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -0,0 +1,12 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/call-generic-method-fail.rs:4:5
|
||||
|
|
||||
LL | *t == *t
|
||||
| ^^^^^^^^ expected `host`, found `true`
|
||||
|
|
||||
= note: expected constant `host`
|
||||
found constant `true`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
@ -1,8 +1,8 @@
|
||||
//! Basic test for calling methods on generic type parameters in `const fn`.
|
||||
|
||||
// known-bug: #110395
|
||||
// check-pass
|
||||
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_trait_impl, effects)]
|
||||
|
||||
struct S;
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/call-generic-method-pass.rs:18:32
|
||||
|
|
||||
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
@ -3,6 +3,7 @@
|
||||
#![feature(
|
||||
associated_type_bounds,
|
||||
const_trait_impl,
|
||||
effects,
|
||||
const_cmp,
|
||||
)]
|
||||
|
||||
|
@ -1,39 +1,16 @@
|
||||
error[E0635]: unknown feature `const_cmp`
|
||||
--> $DIR/const-impl-trait.rs:6:5
|
||||
|
|
||||
LL | const_cmp,
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const-impl-trait.rs:11:30
|
||||
|
|
||||
LL | const fn cmp(a: &impl ~const PartialEq) -> bool {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const-impl-trait.rs:15:30
|
||||
|
|
||||
LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct)
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const-impl-trait.rs:16:20
|
||||
|
|
||||
LL | -> impl ~const PartialEq + ~const Destruct
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const-impl-trait.rs:23:29
|
||||
|
|
||||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/const-impl-trait.rs:27:29
|
||||
error[E0277]: can't compare `impl PartialEq + Destruct + Copy` with `impl PartialEq + Destruct + Copy`
|
||||
--> $DIR/const-impl-trait.rs:28:17
|
||||
|
|
||||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
|
||||
| ^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `impl PartialEq + Destruct + Copy == impl PartialEq + Destruct + Copy`
|
||||
|
|
||||
= help: the trait `PartialEq<impl PartialEq + Destruct + Copy>` is not implemented for `impl PartialEq + Destruct + Copy`
|
||||
note: required by a bound in `Foo::{opaque#0}`
|
||||
--> $DIR/const-impl-trait.rs:24:22
|
||||
|
|
||||
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy;
|
||||
| ^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0635`.
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// known-bug: #110395
|
||||
#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
|
||||
// check-pass
|
||||
#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const, effects)]
|
||||
|
||||
pub struct A;
|
||||
|
||||
|
@ -1,15 +1,9 @@
|
||||
error[E0635]: unknown feature `const_cmp`
|
||||
--> $DIR/derive-const-use.rs:2:30
|
||||
|
|
||||
LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0635]: unknown feature `const_default_impls`
|
||||
--> $DIR/derive-const-use.rs:2:41
|
||||
--> $DIR/derive-const-use.rs:3:5
|
||||
|
|
||||
LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
LL | const_default_impls, derive_const)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0635`.
|
||||
|
@ -1,7 +1,7 @@
|
||||
// known-bug: #110395
|
||||
// check-pass
|
||||
|
||||
#![feature(derive_const)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_trait_impl, effects)]
|
||||
|
||||
#[derive_const(PartialEq)]
|
||||
pub struct Reverse<T>(T);
|
||||
|
@ -1,10 +0,0 @@
|
||||
error: ~const can only be applied to `#[const_trait]` traits
|
||||
--> $DIR/derive-const-with-params.rs:6:16
|
||||
|
|
||||
LL | #[derive_const(PartialEq)]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
x
Reference in New Issue
Block a user