Skip to content

Commit

Permalink
Rollup merge of rust-lang#71479 - RalfJung:scalar-null-ptr, r=jonas-s…
Browse files Browse the repository at this point in the history
…chievink

add back Scalar::null_ptr

We were a bit overeager with removing this in rust-lang#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 rust-lang#71474
  • Loading branch information
Dylan-DPC authored Apr 23, 2020
2 parents 5f9ffb9 + 5bb1afc commit b107eb5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc_middle/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,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 }
Expand Down

0 comments on commit b107eb5

Please sign in to comment.