Skip to content

Commit 89c2c85

Browse files
Add PartialEq<&B> for &A
1 parent 82a9e87 commit 89c2c85

File tree

2 files changed

+12
-44
lines changed

2 files changed

+12
-44
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,15 @@ trait PartialEq<Rhs: ?Sized = Self> {
344344
}
345345
}
346346

347+
impl<A: ?Sized, B: ?Sized> PartialEq<&B> for &A
348+
where
349+
A: PartialEq<B>,
350+
{
351+
fn eq(&self, other: &&B) -> bool {
352+
PartialEq::eq(*self, *other)
353+
}
354+
}
355+
347356
// FIXME(effects): again, this should not error without Rhs specified
348357
impl PartialEq<str> for str {
349358
fn eq(&self, other: &str) -> bool {
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
1-
warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq`
2-
--> $DIR/minicore.rs:332:9
3-
|
4-
LL | "true" => Ok(true),
5-
| ^^^^^^
6-
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8-
= note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122>
9-
= note: `#[warn(const_patterns_without_partial_eq)]` on by default
10-
11-
warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq`
12-
--> $DIR/minicore.rs:333:9
13-
|
14-
LL | "false" => Ok(false),
15-
| ^^^^^^^
16-
|
17-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18-
= note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122>
19-
201
error[E0493]: destructor of `Self` cannot be evaluated at compile-time
21-
--> $DIR/minicore.rs:494:9
2+
--> $DIR/minicore.rs:503:9
223
|
234
LL | *self = source.clone()
245
| ^^^^^
@@ -27,35 +8,13 @@ LL | *self = source.clone()
278
| value is dropped here
289

2910
error[E0493]: destructor of `T` cannot be evaluated at compile-time
30-
--> $DIR/minicore.rs:504:35
11+
--> $DIR/minicore.rs:513:35
3112
|
3213
LL | const fn drop<T: ~const Destruct>(_: T) {}
3314
| ^ - value is dropped here
3415
| |
3516
| the destructor for this type cannot be evaluated in constant functions
3617

37-
error: aborting due to 2 previous errors; 2 warnings emitted
18+
error: aborting due to 2 previous errors
3819

3920
For more information about this error, try `rustc --explain E0493`.
40-
Future incompatibility report: Future breakage diagnostic:
41-
warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq`
42-
--> $DIR/minicore.rs:332:9
43-
|
44-
LL | "true" => Ok(true),
45-
| ^^^^^^
46-
|
47-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
48-
= note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122>
49-
= note: `#[warn(const_patterns_without_partial_eq)]` on by default
50-
51-
Future breakage diagnostic:
52-
warning: to use a constant of type `&str` in a pattern, the type must implement `PartialEq`
53-
--> $DIR/minicore.rs:333:9
54-
|
55-
LL | "false" => Ok(false),
56-
| ^^^^^^^
57-
|
58-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
59-
= note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122>
60-
= note: `#[warn(const_patterns_without_partial_eq)]` on by default
61-

0 commit comments

Comments
 (0)