Skip to content

Commit f7f5952

Browse files
committed
Add warning label to try_as_mplace
1 parent a1990db commit f7f5952

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: src/librustc_mir/interpret/place.rs

+4
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
241241
// These are defined here because they produce a place.
242242
impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
243243
#[inline(always)]
244+
/// Note: do not call `as_ref` on the resulting place. This function should only be used to
245+
/// read from the resulting mplace, not to get its address back.
244246
pub fn try_as_mplace(
245247
self,
246248
cx: &impl HasDataLayout,
@@ -255,6 +257,8 @@ impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
255257
}
256258

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

0 commit comments

Comments
 (0)