X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_middle%2Fsrc%2Fmir%2Finterpret%2Fpointer.rs;h=4461f4e0568738deccbc4c32c00b134b8debf47f;hb=32360925035716a78509629aeff57208ab312649;hp=813c0912f539679db80f57d1ec455580c0ccb1de;hpb=297a8018b525c28ef10ee6a91d61954839b508b9;p=rust.git diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index 813c0912f53..4461f4e0568 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -163,6 +163,9 @@ pub struct Pointer { } static_assert_size!(Pointer, 16); +// `Option` pointers are also passed around quite a bit +// (but not stored in permanent machine state). +static_assert_size!(Pointer>, 16); // We want the `Debug` output to be readable as it is used by `derive(Debug)` for // all the Miri types. @@ -204,6 +207,16 @@ pub fn into_pointer_or_addr(self) -> Result, Size> { None => Err(self.offset), } } + + /// Returns the absolute address the pointer points to. + /// Only works if Tag::OFFSET_IS_ADDR is true! + pub fn addr(self) -> Size + where + Tag: Provenance, + { + assert!(Tag::OFFSET_IS_ADDR); + self.offset + } } impl Pointer> {