Skip to content

Commit

Permalink
Auto merge of rust-lang#3532 - RalfJung:tb-protectors, r=RalfJung
Browse files Browse the repository at this point in the history
Tree Borrows: first apply transition, then check protector with new 'initialized'
  • Loading branch information
bors committed May 2, 2024
2 parents b0bdbcc + aa986f0 commit ca3defe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down

0 comments on commit ca3defe

Please sign in to comment.