Uh oh!
There was an error while loading. Please reload this page.
Short-circuit Rc/Arc equality checking on equal pointers where T: Eq - #56550
Conversation
rust-highfive
commented
Dec 5, 2018
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Mark-Simulacrum
commented
Dec 5, 2018
oli-obk
left a comment
There was a problem hiding this comment.
Do we have tests anywhere along the lines of
let x = std::rc::Rc::new(std::f32::NAN);assert_ne!(x, x);Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
chpio
commented
Dec 8, 2018
@oli-obk added a few tests, but it think they are somewhat wanky, testing the specific impl. |
alexcrichton
commented
Dec 11, 2018
Thanks for the PR @chpio and sorry for the delay! Initially reading this I was wary that this would break cases like @oli-obk mentioned above, but I think after reading over it this is correct and we should consider merging it. @rfcbot fcp merge For those just joining, this reimplements One minor worry I'd have is that for very simple |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
withoutboats
commented
Dec 11, 2018
We document that Eq is supposed to be reflexive, but unsafe code cannot rely on that, so its plausible that some implementations aren't following that. Isn't it possible this will break someone's code in which they had a non-reflexive PartialEq that still impl'd Eq? Are we fine with that? |
SimonSapin
commented
Dec 11, 2018
Code would only break if it relies on a buggy implementation of |
alexcrichton
commented
Dec 12, 2018
Another good point to bring up @withoutboats! In addition to relying on a buggy |
withoutboats
commented
Dec 12, 2018
I think I'm inclined to agree, mainly from a pragmatic perspective - its not likely to come up in practice. But I'm uncertain what our general guidelines around backwards compatibility in regard to the "guarantees" that are made about the behavior of traits in std. There's nothing For example, members of the team have previously argued that types that implement both |
SimonSapin
commented
Dec 12, 2018
But there’s nothing |
withoutboats
commented
Dec 12, 2018
@SimonSapin Definitely not. This is about backwards compatibility. I bring up unsafe because if the contract were reliable for to avoid UB, breaking that code would clearly be permissible. If Eq were an unsafe trait and we could rely on its reflexivity for memory safety, clearly it would be permissible to break code with a non-reflexive Eq impl, because it failed to uphold the invariants its required to as unsafe code. But the reflexivity is in this different category of contracts, which only exist in the std documentation and aren't part of the language. How do we draw the line about which of those contracts you need to uphold to get backwards compatibility from std, and which are just contracts that std is guaranteeing to uphold? |
alexcrichton
commented
Dec 12, 2018
I think the way I typically approach these kinds of problems is that we strive toward the world we want to be in, for example where That may be a bit cavalier though and certainly isn't as conservative as we could be. In any case one thing I've forgotten is that we could certainly run a crater run for this and just see if there's any impact there initially. @bors: try |
bors
commented
Dec 12, 2018
⌛ Trying commit d828c22 with merge aa49d8ef14939ddec0e34b346b60174a5673d48f... |
bors
commented
Dec 12, 2018
☀️ Test successful - status-travis |
alexcrichton
commented
Dec 12, 2018
@craterbot run start=master#bd47d6825bf4090517549d33cfef10d3300b4a75 end=try#aa49d8ef14939ddec0e34b346b60174a5673d48f mode=build-and-test |
Kimundi
commented
Dec 12, 2018
I see it similar to the ability to define a |
rfcbot
commented
Dec 12, 2018
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Is crater just calling |
memoryruins
commented
Dec 13, 2018
The current agent is in |
craterbot
commented
Dec 16, 2018
🎉 Experiment
|
chpio
commented
Dec 16, 2018
couldn't spot any meaningful regressions here, just some timing or env-var not set failures. is anyone else willing to look into it? |
alexcrichton
commented
Dec 17, 2018
bors
commented
Dec 17, 2018
📌 Commit d828c22 has been approved by |
bors
commented
Dec 19, 2018
Short-circuit Rc/Arc equality checking on equal pointers where T: Eq based on #42965 Is the use of the private trait ok this way? Is there anything else needed for this to get pulled?
Uh oh!
There was an error while loading. Please reload this page.
RalfJung
commented
Dec 19, 2018
Wouldn't it make sense to also do the same when comparing And then comparison of |
chpio
commented
Dec 19, 2018
RalfJung
commented
Dec 19, 2018
@chpio Ah that's why I didn't find it, it's in a different PR. I think such conclusions should be added as comments in the source code, they'll be lost otherwise. |
bors
commented
Dec 19, 2018
☀️ Test successful - status-appveyor, status-travis |
chpio
commented
Dec 19, 2018
hmm, yeah. are you saying i should make a new pr for that? |
RalfJung
commented
Dec 19, 2018
That would be great :) |
add comment to `Rc`/`Arc`'s `Eq` specialization in addition to rust-lang#56550rust-lang#42965 (comment)
based on #42965
Is the use of the private trait ok this way? Is there anything else needed for this to get pulled?