about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-05-02 11:09:01 +0200
committerRalf Jung <post@ralfj.de>2024-05-02 11:09:01 +0200
commitaa986f080080e293d059255baee26638728eaee7 (patch)
tree681bb3ca643ac544a6c22198a1bd4a6a679f84f2 /src
parent1c7e82762f02f8ee6a1e985fdbec3a0e25ec572e (diff)
downloadrust-aa986f080080e293d059255baee26638728eaee7.tar.gz
rust-aa986f080080e293d059255baee26638728eaee7.zip
Tree Borrows: first apply transition, then check protector with new 'initialized'
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs
index 2470624181e..ff4589657af 100644
--- a/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs
+++ b/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs
@@ -106,6 +106,8 @@ impl LocationState {
         let old_perm = self.permission;
         let transition = Permission::perform_access(access_kind, rel_pos, old_perm, protected)
             .ok_or(TransitionError::ChildAccessForbidden(old_perm))?;
+        self.initialized |= !rel_pos.is_foreign();
+        self.permission = transition.applied(old_perm).unwrap();
         // Why do only initialized locations cause protector errors?
         // Consider two mutable references `x`, `y` into disjoint parts of
         // the same allocation. A priori, these may actually both be used to
@@ -123,8 +125,6 @@ impl LocationState {
         if protected && self.initialized && transition.produces_disabled() {
             return Err(TransitionError::ProtectedDisabled(old_perm));
         }
-        self.permission = transition.applied(old_perm).unwrap();
-        self.initialized |= !rel_pos.is_foreign();
         Ok(transition)
     }