rust/compiler/rustc_const_eval/src
bors 9d20fd1098 Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obk
interpret: better control over whether we read data with provenance

The resolution in https://github.com/rust-lang/unsafe-code-guidelines/issues/286 seems to be that when we load data at integer type, we implicitly strip provenance. So let's implement that in Miri at least for scalar loads. This makes use of the fact that `Scalar` layouts distinguish pointer-sized integers and pointers -- so I was expecting some wild bugs where layouts set this incorrectly, but so far that does not seem to happen.

This does not entirely implement the solution to https://github.com/rust-lang/unsafe-code-guidelines/issues/286; we still do the wrong thing for integers in larger types: we will `copy_op` them and then do validation, and validation will complain about the provenance. To fix that we need mutating validation; validation needs to strip the provenance rather than complaining about it. This is a larger undertaking (but will also help resolve https://github.com/rust-lang/miri/issues/845 since we can reset padding to `Uninit`).

The reason this is useful is that we can now implement `addr` as a `transmute` from a pointer to an integer, and actually get the desired behavior of stripping provenance without exposing it!
2022-06-06 13:28:58 +00:00
..
const_eval Add a helper function for checking whether a default function in a trait can be treated as const 2022-05-30 08:52:25 +00:00
interpret Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obk 2022-06-06 13:28:58 +00:00
transform comment 2022-06-02 11:12:12 -04:00
util rustc: Panic by default in DefIdTree::parent 2022-05-02 01:56:50 +03:00
lib.rs Remove #[default..] and add #[const_trait] 2022-05-30 08:52:24 +00:00