-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
std: Standardize (input, output) param orderings #23866
Conversation
This functions swaps the order of arguments to a few functions that previously took (output, input) parameters, but now take (input, output) parameters (in that order). The affected functions are: * ptr::copy * ptr::copy_nonoverlapping * slice::bytes::copy_memory * intrinsics::copy * intrinsics::copy_nonoverlapping Closes rust-lang#22890 [breaking-change]
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
r? @aturon |
} | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[cfg(not(stage0))] | ||
pub use intrinsics::copy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be an off-topic, but I always wanted to ask - why copy
and copy_nonoverlapping
are in ptr
and not in mem
?
mem::copy
- copy memory, totally understandable and resembles memcpy
ptr::copy
- what? copy pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIs that are centered around raw pointers go in std::ptr
currently while those dealing with references go in std::mem
(in general). Also, the _memory
suffix from ptr::copy_memory
was recently dropped as there's probably not much you're copying with pointers other than the memory itself.
…aturon This functions swaps the order of arguments to a few functions that previously took (output, input) parameters, but now take (input, output) parameters (in that order). The affected functions are: * ptr::copy * ptr::copy_nonoverlapping * slice::bytes::copy_memory * intrinsics::copy * intrinsics::copy_nonoverlapping Closes rust-lang#22890 [breaking-change]
Thanks for causing segfaults all over my code with this change that was obviously not in need of an RFC because it was submitted by @alexcrichton himself. This is what one has to expect from |
IIRC, stable isn't really stable until 1.0 (or maybe beta?). As is, we're still in alpha. From the blog post:
|
Yeah, who gives a beep about undetectable changes that are guaranteed to introduce memory unsafety all over the place downstream. |
Other people silently breaking your code is really annoying but please remain civil; this is not lkml. You're using an unstable alpha language and Alex made that change to prevent future confusion (users generally expect copy to be from-to). |
You're conflating breaking with introducing undefined behavior that cannot be detected without manually auditing every place
I don't read lkml but you're making it sound like a swell place.
Nonsense. |
It's too late now, but I guarantee this will confuse a large number of people coming from C and expecting a memcpy replacement. Though I suppose that bridge is already crossed by |
Regarding the confusion, I honestly think that if people blindly write code expecting it to be the same as in some other language then that's on them. If it were named the same then yeah I would agree that could be misleading. |
(not trying to be vitriolic) Was this ever discussed in an RFC? This seems like something that would have happened in one of the stabilization RFCs, and I stopped subscribing to rustc dev a couple months ago (mailbox was becoming too fat) |
@aturon @alexcrichton Whoa, this was not the right call. I'm with the others. If i had known about this, I would be completely opposed. |
I think this should be reverted. Submitted #24142 to revert it. |
@alexcrichton what about |
Swap order of input and output parameters of ptr::copy_nonoverlapping (rust-lang/rust#23866), remove usage of std::num::Int (rust-lang/rust#23549), change (rust-lang/rust#23860).
Swap order of input and output parameters of ptr::copy_nonoverlapping (rust-lang/rust#23866), remove usage of std::num::Int (rust-lang/rust#23549), change (rust-lang/rust#23860).
This functions swaps the order of arguments to a few functions that previously
took (output, input) parameters, but now take (input, output) parameters (in
that order).
The affected functions are:
Closes #22890
[breaking-change]