miri::borrow_tracker::tree_borrows::tree

Struct LocationState

Source
pub(super) struct LocationState {
    initialized: bool,
    permission: Permission,
    idempotent_foreign_access: IdempotentForeignAccess,
}
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.

§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

fn new_uninit(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 Active. sifa is the (strongest) idempotent foreign access, see foreign_access_skipping.rs

Source

fn new_init(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 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( &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 shoud 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 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

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§

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, dst: *mut u8)

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