rust/library/core/src
bors e4b9f86054 Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen
Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does

I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`.  Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist.

The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`.  This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing.

Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them.

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936>

cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472`

Fixes #106369
Fixes #73258
2023-03-15 11:44:12 +00:00
..
alloc
array Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
async_iter
cell
char
cmp Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
convert Add examples section which demonstrates the behaviour (specifically the sign positive aspect) 2023-03-09 20:44:11 +00:00
ffi Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubilee 2023-03-02 02:41:42 +00:00
fmt
future Remove identity_future indirection 2023-03-08 15:37:14 +01:00
hash
intrinsics Remove DropAndReplace terminator 2023-03-07 14:25:22 +01:00
iter Rollup merge of #107890 - obeis:mapping-to-unit, r=cjgillot 2023-02-26 00:46:25 +01:00
macros
mem
net Add tracking issue 2023-02-26 13:50:10 +01:00
num Rollup merge of #106633 - c410-f3r:stabilize-nonzero_bits, r=dtolnay 2023-03-11 15:43:12 +01:00
ops
panic
prelude
ptr Improved implementation and comments after code review feedback 2023-03-14 22:24:28 -07:00
slice Use nuw when calculating slice lengths from Ranges 2023-03-05 15:15:22 -08:00
str Auto merge of #105117 - pitaj:debug_asserts, r=the8472 2023-03-05 19:35:44 +00:00
sync Rollup merge of #108419 - tgross35:atomic-as-ptr, r=m-ou-se 2023-03-13 21:55:35 +01:00
task
unicode
any.rs Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
arch.rs
ascii.rs
asserting.rs
bool.rs
borrow.rs
cell.rs Rollup merge of #106921 - madsmtm:cell-memory-layout, r=dtolnay 2023-03-10 19:59:17 +01:00
clone.rs
cmp.rs Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
default.rs
error.md
error.rs
hint.rs
internal_macros.rs
intrinsics.rs Improved implementation and comments after code review feedback 2023-03-14 22:24:28 -07:00
lib.rs Revert "Stabilize #![feature(target_feature_11)]" 2023-03-02 13:41:17 +01:00
marker.rs may not => cannot 2023-03-08 00:00:18 +00:00
option.rs Clarify the text of some comments 2023-03-12 16:30:51 -07:00
panic.rs
panicking.rs
pin.rs
primitive_docs.rs Clarify that Copy is a trait in array docs 2023-02-27 15:16:39 +00:00
primitive.rs
result.rs
time.rs
tuple.rs
unit.rs