@@ -157,7 +157,6 @@ impl<Prov: Provenance> MemPlace<Prov> {
157157 }
158158
159159 /// Turn a mplace into a (thin or wide) pointer, as a reference, pointing to the same space.
160- /// This is the inverse of `ref_to_mplace`.
161160 #[ inline( always) ]
162161 pub fn to_ref ( self , cx : & impl HasDataLayout ) -> Immediate < Prov > {
163162 match self . meta {
@@ -415,7 +414,7 @@ where
415414 }
416415
417416 /// Take a value, which represents a (thin or wide) reference, and make it a place.
418- /// Alignment is just based on the type. This is the inverse of `MemPlace::to_ref ()`.
417+ /// Alignment is just based on the type. This is the inverse of `mplace_to_ref ()`.
419418 ///
420419 /// Only call this if you are sure the place is "valid" (aligned and inbounds), or do not
421420 /// want to ever use the place for memory access!
@@ -438,6 +437,18 @@ where
438437 Ok ( MPlaceTy :: from_aligned_ptr_with_meta ( ptr. to_pointer ( self ) ?, layout, meta) )
439438 }
440439
440+ /// Turn a mplace into a (thin or wide) mutable raw pointer, pointing to the same space.
441+ /// `align` information is lost!
442+ /// This is the inverse of `ref_to_mplace`.
443+ pub fn mplace_to_ref (
444+ & self ,
445+ mplace : & MPlaceTy < ' tcx , M :: Provenance > ,
446+ ) -> InterpResult < ' tcx , ImmTy < ' tcx , M :: Provenance > > {
447+ let imm = mplace. to_ref ( self ) ;
448+ let layout = self . layout_of ( Ty :: new_mut_ptr ( self . tcx . tcx , mplace. layout . ty ) ) ?;
449+ Ok ( ImmTy :: from_immediate ( imm, layout) )
450+ }
451+
441452 /// Take an operand, representing a pointer, and dereference it to a place.
442453 /// Corresponds to the `*` operator in Rust.
443454 #[ instrument( skip( self ) , level = "debug" ) ]
0 commit comments