about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-27 01:00:05 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-01-07 15:41:48 +0100
commitf7f59522b6354d66cf1f08ff0b665d3699acd98c (patch)
tree065749f463e3ff50bdf38a947b3dd0705a66a7e3
parenta1990db7c68ead195d1ddf4b245e3c0e6f721fbc (diff)
downloadrust-f7f59522b6354d66cf1f08ff0b665d3699acd98c.tar.gz
rust-f7f59522b6354d66cf1f08ff0b665d3699acd98c.zip
Add warning label to `try_as_mplace`
-rw-r--r--src/librustc_mir/interpret/place.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs
index f5e8d052b21..1f7db45ccff 100644
--- a/src/librustc_mir/interpret/place.rs
+++ b/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()
     }