Add PartialEq<&B> for &A

This commit is contained in:
Michael Goulet 2023-11-27 16:25:36 +00:00
parent 82a9e872d8
commit 89c2c85fe1
2 changed files with 12 additions and 44 deletions

View File

@ -344,6 +344,15 @@ trait PartialEq<Rhs: ?Sized = Self> {
}
}
impl<A: ?Sized, B: ?Sized> PartialEq<&B> for &A
where
A: PartialEq<B>,
{
fn eq(&self, other: &&B) -> bool {
PartialEq::eq(*self, *other)
}
}
// FIXME(effects): again, this should not error without Rhs specified
impl PartialEq<str> for str {
fn eq(&self, other: &str) -> bool {

View File

@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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: ~const Destruct>(_: 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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/116122>
= note: `#[warn(const_patterns_without_partial_eq)]` on by default