rust/compiler/rustc_middle/src
bors dffea43fc1 Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121
make &mut !Unpin not dereferenceable, and Box<!Unpin> not noalias

See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 and [this LLVM discussion](https://discourse.llvm.org/t/interaction-of-noalias-and-dereferenceable/66979). The exact semantics of how `noalias` and `dereferenceable` interact are unclear, and `@comex` found a case of LLVM actually exploiting that ambiguity for optimizations. I think for now we should treat LLVM `dereferenceable` as implying a "fake read" to happen immediately at the top of the function (standing in for the spurious reads that LLVM might introduce), and that fake read is subject to all the usual `noalias` restrictions. This means we cannot put `dereferenceable` on `&mut !Unpin` references as those references can alias with other references that are being read and written inside the function (e.g. for self-referential generators), meaning the fake read introduces aliasing conflicts with those other accesses.

For `&` this is already not a problem due to https://github.com/rust-lang/rust/pull/98017 which removed the `dereferenceable` attribute for other reasons.

Regular `&mut Unpin` references are unaffected, so I hope the impact of this is going to be tiny.

The first commit does some refactoring of the `PointerKind` enum since I found the old code very confusing each time I had to touch it. It doesn't change behavior.

Fixes https://github.com/rust-lang/miri/issues/2714

EDIT: Turns out our `Box<!Unpin>` treatment was incorrect, too, so the PR also fixes that now (in codegen and Miri): we do not put `noalias` on these boxes any more.
2023-02-07 03:35:10 +00:00
..
dep_graph
hir Improve pretty-printing of HirIdValidator errors 2023-02-01 20:09:22 +01:00
infer
middle
mir Put a DefId in AggregateKind. 2023-02-02 23:09:51 +00:00
query Auto merge of #107463 - Dylan-DPC:rollup-6mq1li8, r=Dylan-DPC 2023-01-30 11:14:21 +00:00
thir
traits Rollup merge of #106477 - Nathan-Fenner:nathanf/refined-error-span-trait-impl, r=compiler-errors 2023-02-06 21:16:39 +01:00
ty Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121 2023-02-07 03:35:10 +00:00
util
arena.rs intern external constraints 2023-02-03 21:36:59 +00:00
error.rs
lib.rs
lint.rs
macros.rs
metadata.rs
tests.rs
thir.rs
values.rs