std: Remove #[old_orphan_check] from PartialEq
This is a deprecated attribute that is slated for removal, and it also affects all implementors of the trait. This commit removes the attribute and fixes up implementors accordingly. The primary implementation which was lost was the ability to compare `&[T]` and `Vec<T>` (in that order). This change also modifies the `assert_eq!` macro to not consider both directions of equality, only the one given in the left/right forms to the macro. This modification is motivated due to the fact that `&[T] == Vec<T>` no longer compiles, causing hundreds of errors in unit tests in the standard library (and likely throughout the community as well). cc #19470 [breaking-change]
This commit is contained in:
parent
80bf31dd51
commit
5cf126ae2f
19 changed files with 77 additions and 86 deletions
|
|
@ -37,7 +37,7 @@ number of elements.
|
|||
|
||||
```rust
|
||||
let x: Vec<u32> = vec![1, 2, 3];
|
||||
# assert_eq!(&[1,2,3], &x);
|
||||
# assert_eq!(x, [1, 2, 3]);
|
||||
```
|
||||
|
||||
This can't be an ordinary function, because it takes any number of arguments.
|
||||
|
|
@ -51,7 +51,7 @@ let x: Vec<u32> = {
|
|||
temp_vec.push(3);
|
||||
temp_vec
|
||||
};
|
||||
# assert_eq!(&[1,2,3], &x);
|
||||
# assert_eq!(x, [1, 2, 3]);
|
||||
```
|
||||
|
||||
We can implement this shorthand, using a macro: [^actual]
|
||||
|
|
@ -73,7 +73,7 @@ macro_rules! vec {
|
|||
};
|
||||
}
|
||||
# fn main() {
|
||||
# assert_eq!([1,2,3], vec![1,2,3]);
|
||||
# assert_eq!(vec![1,2,3], [1, 2, 3]);
|
||||
# }
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue