diff options
| author | Ralf Jung <post@ralfj.de> | 2022-08-28 13:01:56 -0400 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-08-28 13:05:34 -0400 |
| commit | c46e803aaf5a0bfc5dfcd1570349eee71ce81634 (patch) | |
| tree | 3af9c920cd6b8b8611d64986b0591b3b15b1c309 | |
| parent | 1a1220c5e4e0afa97a053536254dddf6a68551f7 (diff) | |
| download | rust-c46e803aaf5a0bfc5dfcd1570349eee71ce81634.tar.gz rust-c46e803aaf5a0bfc5dfcd1570349eee71ce81634.zip | |
improve OFFSET_IS_ADDR docs
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/pointer.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index 5fa802236ed..95e52e391d8 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -107,8 +107,12 @@ impl<T: HasDataLayout> PointerArithmetic for T {} /// pointer), but `derive` adds some unnecessary bounds. pub trait Provenance: Copy + fmt::Debug { /// Says whether the `offset` field of `Pointer`s with this provenance is the actual physical address. - /// If `true, ptr-to-int casts work by simply discarding the provenance. - /// If `false`, ptr-to-int casts are not supported. The offset *must* be relative in that case. + /// - If `false`, the offset *must* be relative. This means the bytes representing a pointer are + /// different from what the Abstract Machine prescribes, so the interpreter must prevent any + /// operation that would inspect the underlying bytes of a pointer, such as ptr-to-int + /// transmutation. A `ReadPointerAsBytes` error will be raised in such situations. + /// - If `true`, the interpreter will permit operations to inspect the underlying bytes of a + /// pointer, and implement ptr-to-int transmutation by stripping provenance. const OFFSET_IS_ADDR: bool; /// We also use this trait to control whether to abort execution when a pointer is being partially overwritten |
