diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-04-23 20:35:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-23 20:35:07 +0200 |
| commit | b107eb5ea4bdf1bc3f6ce7637a9d1980f8045117 (patch) | |
| tree | 5e5d52670664d8541e938acf9b390aad4c8a341e | |
| parent | 5f9ffb9c0237314c267736bfe7dc12b91e18141f (diff) | |
| parent | 5bb1afc7e701594d655e3f7271adb87624b0b2ae (diff) | |
| download | rust-b107eb5ea4bdf1bc3f6ce7637a9d1980f8045117.tar.gz rust-b107eb5ea4bdf1bc3f6ce7637a9d1980f8045117.zip | |
Rollup merge of #71479 - RalfJung:scalar-null-ptr, r=jonas-schievink
add back Scalar::null_ptr We were a bit overeager with removing this in https://github.com/rust-lang/rust/pull/71005, Miri uses this function quite a bit. The important part is that the `Place::null` methods are gone. :) r? @jonas-schievink @oli-obk Fixes https://github.com/rust-lang/rust/issues/71474
| -rw-r--r-- | src/librustc_middle/mir/interpret/value.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/librustc_middle/mir/interpret/value.rs b/src/librustc_middle/mir/interpret/value.rs index 25fa3e5e8e0..f3c1c87dad4 100644 --- a/src/librustc_middle/mir/interpret/value.rs +++ b/src/librustc_middle/mir/interpret/value.rs @@ -189,6 +189,11 @@ impl<'tcx, Tag> Scalar<Tag> { } #[inline] + pub fn null_ptr(cx: &impl HasDataLayout) -> Self { + Scalar::Raw { data: 0, size: cx.data_layout().pointer_size.bytes() as u8 } + } + + #[inline] pub fn zst() -> Self { Scalar::Raw { data: 0, size: 0 } } |
