-
Notifications
You must be signed in to change notification settings - Fork 13.3k
It's weird that cmp::Ord methods can't take &const T without purity. #5208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You should be able to freeze |
Hmm, patrick points out that since now |
Actually I think that only helps a little bit. Using |
What is dangerous about it? It is no problem to freeze data more than once. Also, |
(Presuming we remove purity, by the way) |
(It is also true that if an |
This should fail inside |
Yes, this will fail. |
The fact that this code will fail is only incidentally related to |
Sorry, I shouldn't have phrased as that last sentence as "what you are really saying". It sounds hostile and I don't mean to put words in your mouth. What I mean is, "So in short, I think that the real question is whether to keep the write barrier approach or to use purity". |
(In case it's unclear, I still favor the write barriers over purity. For one thing, if we removed the dynamic write barriers, you simply would not be able to convert an |
Hmm, I had thought this would just be a library gripe rather than going down to the system itself. It didn't occur to me that If so I will continue hacking on my fibonacci heap and see if needing to go from (Also, if so, I wonder -- what use remains for |
I hope to remove &const as well as purity. You do know how you could re-code that example you gave so that it works, right? |
The reason you can't take the address of a dereference an &const ~T (without purity) is that you can't be sure someone else doesn't have an identical |
(More accurately, what's illegal is |
You do know how you could re-code that example you gave so that it works, right? Yeah, in the specific example it is clear. But I am worried that the example could be a simplified version of something someone might run into, where the problem is buried underneath some layers of abstraction (e.g., they want to put |
what's illegal is &const **x where x has type &const ~T, but that's what Eq would need to do to recurse and compare the type T Oh, oh, I understand. Eq/Ord needs to do a So because eq/ord with &const would no doubt be fine under the purity system (because they don't take user-provided closures to call), it would be safe to write them taking &const in this system and doing something unsafe inside, right? (Of course it wouldn't be fair to ask user-provided eq implementations to do that, though.) |
Yes. |
I don't understand this entire discussion, but it seems like the issue will go away when const and/or pure are removed, so I'm closing. In the subject line, RFCs should propose something specific that needs to be changed, rather than making a declarative statement about an existing problem (the latter would be a bug, not an RFC). |
rustup rust-lang#69325, update test stderr changelog: none
I am hacking up a fibonacci heap implementation, in which all the nodes are
@mut
cells, and unless I want to growT:Copy
s all over the place, comparing against data already in the heap is impossible, because today you need immutable pointers to useOrd
.The text was updated successfully, but these errors were encountered: