Uh oh!
There was an error while loading. Please reload this page.
std: Remove #[old_orphan_check] from PartialEq - #23288
Conversation
alexcrichton
commented
Mar 11, 2015
r? @aturon |
rust-highfive
commented
Mar 11, 2015
r? @gankro (rust_highfive has picked a reviewer for you, use r? to override) |
alexcrichton
commented
Mar 11, 2015
japaric
commented
Mar 12, 2015
One possible way to retain the impl<T,U>PartialEq<T,U>for&[T]whereU:RhsSlice{ .. }And then |
alexcrichton
commented
Mar 12, 2015
I think for now we wouldn't necessarily want to commit to a trait like that, but it should be a backwards compatible extension to allow comparison of slices to more types, right? Another option would be to leverage |
japaric
commented
Mar 13, 2015
Another idea (cc @nikomatsakis): change the
Advantages
Disadvantages:
|
alexcrichton
commented
Mar 13, 2015
Oh wow, that is an interesting idea! Some thoughts:
Curious what others think though! |
japaric
commented
Mar 13, 2015
I though about this and I think is possible to maintain the evaluation order in the "reverse" case with the help of temporaries. Updated algorithm:
Yes, it's unfortunate. I think the right way to ensure symmetry is to use the type system: (a) use a blanket implementation like I mentioned above (issue: overlapping impls), or (b) make the compiler automatically derive the reverse case even if it has to bypass the orphan_check (can this lead to a violation of coherence?). |
alexcrichton
commented
Mar 13, 2015
Hm yeah, I'd be fine with that.
I would personally see this as pushing the envelope of a "bit too much magic" for a case that may not be worth it. |
bors
commented
Mar 17, 2015
☔ The latest upstream changes (presumably #23104) made this pull request unmergeable. Please resolve the merge conflicts. |
aturon
commented
Mar 17, 2015
I think we may want to consider some compiler help for symmetry, as @japaric is proposing, at some point in the future but there's just not scope for it right now. For the time being, I think we should move forward on this PR so that we can remove the feature gate, and then separately consider simpler workarounds like the blanket impl @japaric initially suggested. |
aturon
commented
Mar 17, 2015
So, the thing that makes me most uncomfortable here is the removal of two-sides checks on That said, I don't think there's a strong reason for All that said... I'm not really sure what else to do. Once generic conversion traits land, we could perhaps use something like the Thoughts? |
alexcrichton
commented
Mar 17, 2015
I agree that this makes me feel a little uneasy, but I also agree that this impl would be fine to land as well: impl<T,R:As<[T]>>PartialEq<R>for[T]{fneq(&self,other:&R) -> bool{ ...}} |
aturon
commented
Mar 17, 2015
OK, let's stage this after the conversion trait implementation, which is in progress. (Might be good in the meantime to quickly try this with |
nikomatsakis
commented
Mar 17, 2015
FWIW, I think I agree with @aturon's assessment of "maybe we can improve this in the future but we should move forward for now". It is mildly annoying that you have to put the vec on the left, though I wonder if this will just be a thing that people get used to. (The orphan rules strongly suggest that you should favor the LHS for the more "specific" type...) |
alexcrichton
commented
Mar 17, 2015
For posterity, it looks like |
bors
commented
Mar 24, 2015
☔ The latest upstream changes (presumably #23654) made this pull request unmergeable. Please resolve the merge conflicts. |
bors
commented
Mar 28, 2015
☔ The latest upstream changes (presumably #23796) made this pull request unmergeable. Please resolve the merge conflicts. |
alexcrichton
commented
Mar 31, 2015
ping @aturon, this likely needs a decision pretty soon. |
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 rust-lang#19470 [breaking-change]
be173f8 to
608fff8Compareaturon
commented
Mar 31, 2015
bors
commented
Mar 31, 2015
⌛ Testing commit 608fff8 with merge 1a48efc... |
bors
commented
Mar 31, 2015
💔 Test failed - auto-linux-64-x-android-t |
alexcrichton
commented
Mar 31, 2015
@bors: retry rollup |
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). Closesrust-lang#19470 [breaking-change]
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]andVec<T>(in that order).This change also modifies the
assert_eq!macro to not consider both directionsof 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 longercompiles, causing hundreds of errors in unit tests in the standard library (and
likely throughout the community as well).
Closes#19470
[breaking-change]