Skip to content
Permalink
Browse files

Add warning label to `try_as_mplace`

  • Loading branch information
oli-obk committed Dec 27, 2019
1 parent a1990db commit f7f59522b6354d66cf1f08ff0b665d3699acd98c
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/librustc_mir/interpret/place.rs
@@ -241,6 +241,8 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
// These are defined here because they produce a place.
impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
#[inline(always)]
/// Note: do not call `as_ref` on the resulting place. This function should only be used to
/// read from the resulting mplace, not to get its address back.
pub fn try_as_mplace(
self,
cx: &impl HasDataLayout,
@@ -255,6 +257,8 @@ impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
}

#[inline(always)]
/// Note: do not call `as_ref` on the resulting place. This function should only be used to
/// read from the resulting mplace, not to get its address back.
pub fn assert_mem_place(self, cx: &impl HasDataLayout) -> MPlaceTy<'tcx, Tag> {
self.try_as_mplace(cx).unwrap()
}

0 comments on commit f7f5952

Please sign in to comment.
You can’t perform that action at this time.