Tree Borrows: first apply transition, then check protector with new 'initialized'
This commit is contained in:
parent
1c7e82762f
commit
aa986f0800
@ -106,6 +106,8 @@ fn perform_access(
|
|||||||
let old_perm = self.permission;
|
let old_perm = self.permission;
|
||||||
let transition = Permission::perform_access(access_kind, rel_pos, old_perm, protected)
|
let transition = Permission::perform_access(access_kind, rel_pos, old_perm, protected)
|
||||||
.ok_or(TransitionError::ChildAccessForbidden(old_perm))?;
|
.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?
|
// Why do only initialized locations cause protector errors?
|
||||||
// Consider two mutable references `x`, `y` into disjoint parts of
|
// Consider two mutable references `x`, `y` into disjoint parts of
|
||||||
// the same allocation. A priori, these may actually both be used to
|
// the same allocation. A priori, these may actually both be used to
|
||||||
@ -123,8 +125,6 @@ fn perform_access(
|
|||||||
if protected && self.initialized && transition.produces_disabled() {
|
if protected && self.initialized && transition.produces_disabled() {
|
||||||
return Err(TransitionError::ProtectedDisabled(old_perm));
|
return Err(TransitionError::ProtectedDisabled(old_perm));
|
||||||
}
|
}
|
||||||
self.permission = transition.applied(old_perm).unwrap();
|
|
||||||
self.initialized |= !rel_pos.is_foreign();
|
|
||||||
Ok(transition)
|
Ok(transition)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user