about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-04 21:31:59 +0200
committerGitHub <noreply@github.com>2023-08-04 21:31:59 +0200
commit5e42a2276a1be61598adb9eebebd86f5cc84c78c (patch)
tree72ff6f2b55ac2b10c27704f18380ae6cfaa0cc41 /src
parentb7bfffd3d1cb391edbd86057c0de7c15e75b0e25 (diff)
parent3345077b42ec15a4c85b9f5a4c364ccb599a1d0f (diff)
Rollup merge of #114462 - RalfJung:mplace_to_ref, r=oli-obk
interpret: add mplace_to_ref helper method
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs5
-rw-r--r--src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs5
2 files changed, 4 insertions, 6 deletions
diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
index e929091b396..75e4b5f8466 100644
--- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
+++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
@@ -15,7 +15,7 @@ use rustc_data_structures::fx::FxHashSet;
 use rustc_middle::mir::{Mutability, RetagKind};
 use rustc_middle::ty::{
     self,
-    layout::{HasParamEnv, LayoutOf},
+    layout::HasParamEnv,
     Ty,
 };
 use rustc_target::abi::{Abi, Align, Size};
@@ -993,8 +993,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
 
         // We have to turn the place into a pointer to use the usual retagging logic.
         // (The pointer type does not matter, so we use a raw pointer.)
-        let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, place.layout.ty))?;
-        let ptr = ImmTy::from_immediate(place.to_ref(this), ptr_layout);
+        let ptr = this.mplace_to_ref(place)?;
         // Reborrow it. With protection! That is the entire point.
         let new_perm = NewPermission::Uniform {
             perm: Permission::Unique,
diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
index b2dbe8a70f0..d30745b3b61 100644
--- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
+++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
@@ -7,7 +7,7 @@ use rustc_middle::{
     mir::{Mutability, RetagKind},
     ty::{
         self,
-        layout::{HasParamEnv, LayoutOf},
+        layout::HasParamEnv,
         Ty,
     },
 };
@@ -488,8 +488,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
 
         // We have to turn the place into a pointer to use the usual retagging logic.
         // (The pointer type does not matter, so we use a raw pointer.)
-        let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, place.layout.ty))?;
-        let ptr = ImmTy::from_immediate(place.to_ref(this), ptr_layout);
+        let ptr = this.mplace_to_ref(place)?;
         // Reborrow it. With protection! That is the entire point.
         let new_perm = NewPermission {
             initial_state: Permission::new_active(),