From 89c2c85fe16c8b0551592f3e4d9acc2396087b42 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 27 Nov 2023 16:25:36 +0000 Subject: [PATCH] Add PartialEq<&B> for &A --- .../effects/minicore.rs | 9 ++++ .../effects/minicore.stderr | 47 ++----------------- 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs index d79cf372b87..007d681f3eb 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs @@ -344,6 +344,15 @@ trait PartialEq { } } +impl PartialEq<&B> for &A +where + A: PartialEq, +{ + fn eq(&self, other: &&B) -> bool { + PartialEq::eq(*self, *other) + } +} + // FIXME(effects): again, this should not error without Rhs specified impl PartialEq for str { fn eq(&self, other: &str) -> bool { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr index 19e6f6bffc6..461133e6c3e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr @@ -1,24 +1,5 @@ -warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq` - --> $DIR/minicore.rs:332:9 - | -LL | "true" => Ok(true), - | ^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116122 - = note: `#[warn(const_patterns_without_partial_eq)]` on by default - -warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq` - --> $DIR/minicore.rs:333:9 - | -LL | "false" => Ok(false), - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116122 - error[E0493]: destructor of `Self` cannot be evaluated at compile-time - --> $DIR/minicore.rs:494:9 + --> $DIR/minicore.rs:503:9 | LL | *self = source.clone() | ^^^^^ @@ -27,35 +8,13 @@ LL | *self = source.clone() | value is dropped here error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/minicore.rs:504:35 + --> $DIR/minicore.rs:513:35 | LL | const fn drop(_: T) {} | ^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 2 previous errors; 2 warnings emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0493`. -Future incompatibility report: Future breakage diagnostic: -warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq` - --> $DIR/minicore.rs:332:9 - | -LL | "true" => Ok(true), - | ^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116122 - = note: `#[warn(const_patterns_without_partial_eq)]` on by default - -Future breakage diagnostic: -warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq` - --> $DIR/minicore.rs:333:9 - | -LL | "false" => Ok(false), - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #116122 - = note: `#[warn(const_patterns_without_partial_eq)]` on by default -