Skip to content

Commit c46e803

Browse files
committed
improve OFFSET_IS_ADDR docs
1 parent 1a1220c commit c46e803

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: compiler/rustc_middle/src/mir/interpret/pointer.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ impl<T: HasDataLayout> PointerArithmetic for T {}
107107
/// pointer), but `derive` adds some unnecessary bounds.
108108
pub trait Provenance: Copy + fmt::Debug {
109109
/// Says whether the `offset` field of `Pointer`s with this provenance is the actual physical address.
110-
/// If `true, ptr-to-int casts work by simply discarding the provenance.
111-
/// If `false`, ptr-to-int casts are not supported. The offset *must* be relative in that case.
110+
/// - If `false`, the offset *must* be relative. This means the bytes representing a pointer are
111+
/// different from what the Abstract Machine prescribes, so the interpreter must prevent any
112+
/// operation that would inspect the underlying bytes of a pointer, such as ptr-to-int
113+
/// transmutation. A `ReadPointerAsBytes` error will be raised in such situations.
114+
/// - If `true`, the interpreter will permit operations to inspect the underlying bytes of a
115+
/// pointer, and implement ptr-to-int transmutation by stripping provenance.
112116
const OFFSET_IS_ADDR: bool;
113117

114118
/// We also use this trait to control whether to abort execution when a pointer is being partially overwritten

0 commit comments

Comments
 (0)