Skip to content

Commit d5e9e94

Browse files
committed
add method to get the mutability of an AllocId
1 parent affe0d3 commit d5e9e94

File tree

1 file changed

+7
-0
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+7
-0
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+7
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
520520

521521
/// Gives raw access to the `Allocation`, without bounds or alignment checks.
522522
/// The caller is responsible for calling the access hooks!
523+
///
524+
/// You almost certainly want to use `get_ptr_alloc`/`get_ptr_alloc_mut` instead.
523525
fn get_alloc_raw(
524526
&self,
525527
id: AllocId,
@@ -589,6 +591,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
589591
Ok(&self.get_alloc_raw(id)?.extra)
590592
}
591593

594+
/// Return the `mutability` field of the given allocation.
595+
pub fn get_alloc_mutability<'a>(&'a self, id: AllocId) -> InterpResult<'tcx, Mutability> {
596+
Ok(self.get_alloc_raw(id)?.mutability)
597+
}
598+
592599
/// Gives raw mutable access to the `Allocation`, without bounds or alignment checks.
593600
/// The caller is responsible for calling the access hooks!
594601
///

0 commit comments

Comments
 (0)