Skip to content

Commit

Permalink
Add PartialEq<&B> for &A
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Nov 28, 2023
1 parent 82a9e87 commit 89c2c85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 44 deletions.
9 changes: 9 additions & 0 deletions tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
47 changes: 3 additions & 44 deletions tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr
Original file line number Diff line number Diff line change
@@ -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()
| ^^^^^
Expand All @@ -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

0 comments on commit 89c2c85

Please sign in to comment.