@@ -418,7 +418,7 @@ where
418418 }
419419
420420 /// Take a value, which represents a (thin or wide) reference, and make it a place.
421- /// Alignment is just based on the type. This is the inverse of `mplace_to_ptr ()`.
421+ /// Alignment is just based on the type. This is the inverse of `mplace_to_ref ()`.
422422 ///
423423 /// Only call this if you are sure the place is "valid" (aligned and inbounds), or do not
424424 /// want to ever use the place for memory access!
@@ -440,7 +440,7 @@ where
440440
441441 /// Turn a mplace into a (thin or wide) mutable raw pointer, pointing to the same space.
442442 /// `align` information is lost!
443- /// This is the inverse of `ref_to_mplace `.
443+ /// This is the inverse of `ptr_to_mplace `.
444444 pub fn mplace_to_ptr (
445445 & self ,
446446 mplace : & MPlaceTy < ' tcx , M :: Provenance > ,
@@ -450,6 +450,22 @@ where
450450 interp_ok ( ImmTy :: from_immediate ( imm, layout) )
451451 }
452452
453+ /// Turn a mplace into a (thin or wide) mutable reference, pointing to the same space.
454+ /// `align` information is lost!
455+ /// This is the inverse of `ref_to_mplace`.
456+ pub fn mplace_to_mut_ref (
457+ & self ,
458+ mplace : & MPlaceTy < ' tcx , M :: Provenance > ,
459+ ) -> InterpResult < ' tcx , ImmTy < ' tcx , M :: Provenance > > {
460+ let imm = mplace. mplace . to_ref ( self ) ;
461+ let layout = self . layout_of ( Ty :: new_mut_ref (
462+ self . tcx . tcx ,
463+ self . tcx . tcx . lifetimes . re_erased ,
464+ mplace. layout . ty ,
465+ ) ) ?;
466+ interp_ok ( ImmTy :: from_immediate ( imm, layout) )
467+ }
468+
453469 /// Take an operand, representing a pointer, and dereference it to a place.
454470 /// Corresponds to the `*` operator in Rust.
455471 #[ instrument( skip( self ) , level = "trace" ) ]
0 commit comments