LocationState in miri::borrow_tracker::tree_borrows::tree - Rust
Description: Data for a reference at single location.

Skip to main content

## LocationState

# Struct LocationState

Source

    pub(super) struct LocationState {
        accessed: bool,
        permission: Permission,
        idempotent_foreign_access: IdempotentForeignAccess,
    }

Expand description

Data for a reference at single location.

## Fields§

§`accessed: bool`

A location is “accessed” 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 accessed forever. For accessed locations, “permission” is the current permission. However, for non-accessed 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 non-accessed 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 accessed, as if the allocation was a write access.

§`permission: Permission`

This pointer’s current permission / future initial permission.

§`idempotent_foreign_access: IdempotentForeignAccess`

See `foreign_access_skipping.rs`. Stores an idempotent foreign access for this location and its children. For correctness, this must not be too strong, and the recorded idempotent foreign access of all children must be at least as strong as this. For performance, it should be as strong as possible.

## Implementations§

Source§

### impl LocationState

Source

#### pub fn new_non_accessed( permission: Permission, sifa: IdempotentForeignAccess, ) -> 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 `Unique`. `sifa` is the (strongest) idempotent foreign access, see `foreign_access_skipping.rs`

Source

#### pub fn new_accessed( permission: Permission, sifa: IdempotentForeignAccess, ) -> 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. `sifa` is the (strongest) idempotent foreign access, see `foreign_access_skipping.rs`

Source

#### pub fn accessed(&self) -> bool

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

Source

#### pub fn permission(&self) -> Permission

Source

#### fn perform_transition( &mut self, idx: UniIndex, nodes: &mut UniValMap<Node>, exposed_cache: &mut ExposedCache, access_kind: AccessKind, relatedness: AccessRelatedness, protected: bool, diagnostics: &DiagnosticInfo, ) -> Result<(), TransitionError>

Performs an access on this index and updates node, perm and wildcard_state to reflect the transition.

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 accessed,
- updating the accessed status (child accesses produce accessed locations).

Source

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

Tree traversal optimizations. See `foreign_access_skipping.rs`. This checks if such a foreign access can be skipped.

Source

#### fn record_new_access( &mut self, access_kind: AccessKind, rel_pos: AccessRelatedness, )

Records a new access, so that future access can potentially be skipped by `skip_if_known_noop`. This must be called on child accesses, and otherwise should be called on foreign accesses for increased performance. It should not be called when `skip_if_known_noop` indicated skipping, since it then is a no-op. See `foreign_access_skipping.rs`

## Trait Implementations§

Source§

### impl Clone for LocationState

Source§

#### fn clone(&self) -> LocationState

Returns a duplicate 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

Tests for `self` and `other` values to be equal, and is used by `==`.
1.0.0 · Source§

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

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§

§

### impl Freeze for LocationState

§

### impl RefUnwindSafe for LocationState

§

### impl Send for LocationState

§

### impl Sync for LocationState

§

### impl Unpin for LocationState

§

### impl UnsafeUnpin for LocationState

§

### impl UnwindSafe for LocationState

## 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> CloneToUninit for T
where T: Clone,

Source§

#### unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (`clone_to_uninit`)
Performs copy-assignment from `self` to `dest`. 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

Source§

#### type Output = T

Should always be `Self`
Source§

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

Source§

#### 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§

#### 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>,

Source§

#### 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>,

Source§

#### 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: 3 bytes