Skip to content

Commit ca3defe

Browse files
committed
Auto merge of rust-lang#3532 - RalfJung:tb-protectors, r=RalfJung
Tree Borrows: first apply transition, then check protector with new 'initialized'
2 parents b0bdbcc + aa986f0 commit ca3defe

File tree

1 file changed

+2
-2
lines changed
  • src/tools/miri/src/borrow_tracker/tree_borrows

1 file changed

+2
-2
lines changed

src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ impl LocationState {
106106
let old_perm = self.permission;
107107
let transition = Permission::perform_access(access_kind, rel_pos, old_perm, protected)
108108
.ok_or(TransitionError::ChildAccessForbidden(old_perm))?;
109+
self.initialized |= !rel_pos.is_foreign();
110+
self.permission = transition.applied(old_perm).unwrap();
109111
// Why do only initialized locations cause protector errors?
110112
// Consider two mutable references `x`, `y` into disjoint parts of
111113
// the same allocation. A priori, these may actually both be used to
@@ -123,8 +125,6 @@ impl LocationState {
123125
if protected && self.initialized && transition.produces_disabled() {
124126
return Err(TransitionError::ProtectedDisabled(old_perm));
125127
}
126-
self.permission = transition.applied(old_perm).unwrap();
127-
self.initialized |= !rel_pos.is_foreign();
128128
Ok(transition)
129129
}
130130

0 commit comments

Comments
 (0)