diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-08-09 17:34:52 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-09 17:34:52 +0530 |
| commit | 7efe24c3ed070193ca64f402036166c8ab0c44b3 (patch) | |
| tree | 5881ceeaf183e0ae93dc9cef08f5a5bf819a5320 /compiler/rustc_const_eval/src | |
| parent | e41be25f0664566c6b3a8105ff306c40713047de (diff) | |
| parent | 54b122e9132937bb0aa3514b3d5852b68e7ddf04 (diff) | |
| download | rust-7efe24c3ed070193ca64f402036166c8ab0c44b3.tar.gz rust-7efe24c3ed070193ca64f402036166c8ab0c44b3.zip | |
Rollup merge of #100181 - RalfJung:alloc-ref-mutability, r=jackh726
add method to get the mutability of an AllocId Miri needs this for https://github.com/rust-lang/miri/issues/2463.
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/memory.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index ed2c4edf9dd..75528d6140c 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -520,6 +520,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { /// Gives raw access to the `Allocation`, without bounds or alignment checks. /// The caller is responsible for calling the access hooks! + /// + /// You almost certainly want to use `get_ptr_alloc`/`get_ptr_alloc_mut` instead. fn get_alloc_raw( &self, id: AllocId, @@ -589,6 +591,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Ok(&self.get_alloc_raw(id)?.extra) } + /// Return the `mutability` field of the given allocation. + pub fn get_alloc_mutability<'a>(&'a self, id: AllocId) -> InterpResult<'tcx, Mutability> { + Ok(self.get_alloc_raw(id)?.mutability) + } + /// Gives raw mutable access to the `Allocation`, without bounds or alignment checks. /// The caller is responsible for calling the access hooks! /// |
