Struct miri::borrow_tracker::tree_borrows::tree::LocationState

source ·
pub(super) struct LocationState {
    initialized: bool,
    permission: Permission,
    latest_foreign_access: Option<AccessKind>,
}
Expand description

Data for a single location.

Fields§

§initialized: bool

A location is initialized when it is child-accessed for the first time (and the initial retag initializes the location for the range covered by the type), and it then stays initialized forever. For initialized locations, “permission” is the current permission. However, for uninitialized locations, we still need to track the “future initial permission”: this will start out to be default_initial_perm, but foreign accesses need to be taken into account. Crucially however, while transitions to Disabled would usually be UB if this location is protected, that is not the case for uninitialized locations. Instead we just have a latent “future initial permission” of Disabled, causing UB only if an access is ever actually performed. Note that the tree root is also always initialized, as if the allocation was a write access.

§permission: Permission

This pointer’s current permission / future initial permission.

§latest_foreign_access: Option<AccessKind>

Strongest foreign access whose effects have already been applied to this node and all its children since the last child access. This is None if the most recent access is a child access, Some(Write) if at least one foreign write access has been applied since the previous child access, and Some(Read) if at least one foreign read and no foreign write have occurred since the last child access.

Implementations§

source§

impl LocationState

source

fn new_uninit(permission: Permission) -> Self

Constructs a new initial state. It has neither been accessed, nor been subjected to any foreign access yet. The permission is not allowed to be Active.

source

fn new_init(permission: Permission) -> Self

Constructs a new initial state. It has not yet been subjected to any foreign access. However, it is already marked as having been accessed.

source

pub fn is_initialized(&self) -> bool

Check if the location has been initialized, i.e. if it has ever been accessed through a child pointer.

source

pub fn is_initial(&self) -> bool

Check if the state can exist as the initial permission of a pointer.

Do not confuse with is_initialized, the two are almost orthogonal as apart from Active which is not initial and must be initialized, any other permission can have an arbitrary combination of being initial/initialized. FIXME: when the corresponding assert in tree_borrows/mod.rs finally passes and can be uncommented, remove this #[allow(dead_code)].

source

pub fn permission(&self) -> Permission

source

fn perform_access( &mut self, access_kind: AccessKind, rel_pos: AccessRelatedness, protected: bool, ) -> Result<PermTransition, TransitionError>

Apply the effect of an access to one location, including

  • applying Permission::perform_access to the inner Permission,
  • emitting protector UB if the location is initialized,
  • updating the initialized status (child accesses produce initialized locations).
source

fn skip_if_known_noop( &mut self, access_kind: AccessKind, rel_pos: AccessRelatedness, ) -> ContinueTraversal

Trait Implementations§

source§

impl Clone for LocationState

source§

fn clone(&self) -> LocationState

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LocationState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for LocationState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for LocationState

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for LocationState

source§

fn eq(&self, other: &LocationState) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for LocationState

source§

impl Eq for LocationState

source§

impl StructuralPartialEq for LocationState

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 4 bytes