rust/library/core/src
Dylan DPC 8fa1ed8f12
Rollup merge of #97712 - RalfJung:untyped, r=scottmcm
ptr::copy and ptr::swap are doing untyped copies

The consensus in https://github.com/rust-lang/rust/issues/63159 seemed to be that these operations should be "untyped", i.e., they should treat the data as raw bytes, should work when these bytes violate the validity invariant of `T`, and should exactly preserve the initialization state of the bytes that are being copied. This is already somewhat implied by the description of "copying/swapping size*N bytes" (rather than "N instances of `T`").

The implementations mostly already work that way (well, for LLVM's intrinsics the documentation is not precise enough to say what exactly happens to poison, but if this ever gets clarified to something that would *not* perfectly preserve poison, then I strongly assume there will be some way to make a copy that *does* perfectly preserve poison). However, I had to adjust `swap_nonoverlapping`; after ``@scottmcm's`` [recent changes](https://github.com/rust-lang/rust/pull/94212), that one (sometimes) made a typed copy. (Note that `mem::swap`, which works on mutable references, is unchanged. It is documented as "swapping the values at two mutable locations", which to me strongly indicates that it is indeed typed. It is also safe and can rely on `&mut T` pointing to a valid `T` as part of its safety invariant.)

On top of adding a test (that will be run by Miri), this PR then also adjusts the documentation to indeed stably promise the untyped semantics. I assume this means the PR has to go through t-libs (and maybe t-lang?) FCP.

Fixes https://github.com/rust-lang/rust/issues/63159
2022-07-05 16:04:31 +05:30
..
alloc Rollup merge of #97034 - fee1-dead-contrib:layout-hash, r=dtolnay 2022-05-28 08:45:51 +02:00
array Add Iterator::next_chunk 2022-06-21 08:57:02 +02:00
async_iter Add Stream alias for AsyncIterator 2022-03-15 20:59:13 -07:00
cell Move/rename lazy::{OnceCell, Lazy} to cell::{OnceCell, LazyCell} 2022-06-16 19:53:59 +04:00
char No need to check the assert all the time. 2022-04-16 19:30:23 +01:00
convert Warn on unused doc(hidden) on trait impl items 2022-05-08 22:53:14 +02:00
ffi library: fix uefi va_list type definition 2022-06-25 21:19:09 -04:00
fmt update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
future typos in IntoFuture docs 2022-06-19 17:13:48 +02:00
hash update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
iter clarify that ExactSizeIterator::len returns the remaining length 2022-06-30 19:45:36 +02:00
macros Grammar fix in the compile_error documentation 2022-06-09 12:40:10 +02:00
mem Rollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett 2022-06-20 07:37:40 +09:00
num Fix spelling in SAFETY comment 2022-06-26 19:17:34 -07:00
ops Add a link to the unstable book page on Generator doc comment 2022-06-20 23:19:50 +09:00
panic Auto merge of #96348 - overdrivenpotato:inline-location, r=the8472 2022-04-30 16:33:12 +00:00
prelude Create 2024 edition 2022-04-02 02:45:49 -04:00
ptr Rollup merge of #97712 - RalfJung:untyped, r=scottmcm 2022-07-05 16:04:31 +05:30
slice Auto merge of #93765 - zhangyunhao116:heapsort, r=m-ou-se 2022-06-20 18:09:30 +00:00
str Auto merge of #97367 - WaffleLapkin:stabilize_checked_slice_to_str_conv, r=dtolnay 2022-06-19 05:51:42 +00:00
sync Rollup merge of #97629 - guswynn:exclusive_struct, r=m-ou-se 2022-06-30 19:55:50 +02:00
task Rollup merge of #93966 - rkuhn:patch-1, r=tmandry 2022-05-25 07:08:41 +09:00
unicode Add unicode fast path to is_printable 2022-05-31 10:51:35 +02:00
any.rs Fix typos in Provider API docs 2022-06-10 20:58:27 -07:00
ascii.rs Inline <EscapeDefault as Iterator>::next 2022-03-10 15:35:22 +01:00
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs Stabilize bool::then_some 2022-05-04 13:22:08 +02:00
borrow.rs Make Borrow and BorrowMut impls const 2021-12-04 21:57:39 +09:00
cell.rs Move/rename lazy::{OnceCell, Lazy} to cell::{OnceCell, LazyCell} 2022-06-16 19:53:59 +04:00
clone.rs update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
cmp.rs update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
default.rs Add documentation 2022-04-07 20:03:24 -04:00
hint.rs Clarify unreachable_unchecked docs 2022-05-06 09:34:41 +02:00
internal_macros.rs ignore a doctest for the non-exported macro 2022-05-03 18:33:56 +09:00
intrinsics.rs Rollup merge of #97712 - RalfJung:untyped, r=scottmcm 2022-07-05 16:04:31 +05:30
lazy.rs Move/rename lazy::{OnceCell, Lazy} to cell::{OnceCell, LazyCell} 2022-06-16 19:53:59 +04:00
lib.rs Stabilize const_intrinsic_copy 2022-06-08 20:17:28 +09:00
marker.rs docs: show Clone and Copy on () doc pages 2022-06-07 12:12:49 -07:00
option.rs Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm 2022-05-26 20:59:40 +02:00
panic.rs resolve the conflict in compiler/rustc_session/src/parse.rs 2022-03-16 20:12:30 +08:00
panicking.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
pin.rs Fix the generator example for pin!() 2022-05-05 09:58:13 +10:00
primitive.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
primitive_docs.rs update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
result.rs Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm 2022-05-26 20:59:40 +02:00
time.rs Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett 2022-05-26 20:15:07 -07:00
tuple.rs update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00