Skip to main content

## State

# Enum State

Source

    pub enum State<V> {
        Unreachable,
        Reachable(StateData<V>),
    }

Expand description

Dataflow state.

Every instance specifies a lattice that represents the possible values of a single tracked place. If we call this lattice `V` and set of tracked places `P`, then a `State` is an element of `{unreachable} ∪ (P -> V)`. This again forms a lattice, where the bottom element is `unreachable` and the top element is the mapping `p ↦ ⊤`. Note that the mapping `p ↦ ⊥` is not the bottom element (because joining an unreachable and any other reachable state yields a reachable state). All operations on unreachable states are ignored.

Flooding means assigning a value (by default `⊤`) to all tracked projections of a given place.

## Variants§

§

### Unreachable

§

### Reachable(StateData<V>)

## Implementations§

Source§

### impl<V: Clone + HasBottom> State<V>

Source

#### pub fn new_reachable() -> State<V>

Source

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

Source

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

Source

#### pub fn flood_with(&mut self, place: PlaceRef<'_>, map: &Map<'_>, value: V)

Assign `value` to all places that are contained in `place` or may alias one.

Source

#### pub fn flood(&mut self, place: PlaceRef<'_>, map: &Map<'_>)
where V: HasTop,

Assign `TOP` to all places that are contained in `place` or may alias one.

Source

#### fn flood_discr_with(&mut self, place: PlaceRef<'_>, map: &Map<'_>, value: V)

Assign `value` to the discriminant of `place` and all places that may alias it.

Source

#### pub fn flood_discr(&mut self, place: PlaceRef<'_>, map: &Map<'_>)
where V: HasTop,

Assign `TOP` to the discriminant of `place` and all places that may alias it.

Source

#### pub fn flood_with_tail_elem( &mut self, place: PlaceRef<'_>, tail_elem: Option<TrackElem>, map: &Map<'_>, value: V, )

This method is the most general version of the `flood_*` method.

Assign `value` on the given place and all places that may alias it. In particular, when the given place has a variant downcast, we invoke the function on all the other variants.

`tail_elem` allows to support discriminants that are not a place in MIR, but that we track as such.

Source

#### fn insert_idx( &mut self, target: PlaceIndex, result: ValueOrPlace<V>, map: &Map<'_>, )

Low-level method that assigns to a place. This does nothing if the place is not tracked.

The target place must have been flooded before calling this method.

Source

#### pub fn insert_value_idx(&mut self, target: PlaceIndex, value: V, map: &Map<'_>)

Low-level method that assigns a value to a place. This does nothing if the place is not tracked.

The target place must have been flooded before calling this method.

Source

#### pub fn insert_place_idx( &mut self, target: PlaceIndex, source: PlaceIndex, map: &Map<'_>, )

Copies `source` to `target`, including all tracked places beneath.

If `target` contains a place that is not contained in `source`, it will be overwritten with Top. Also, because this will copy all entries one after another, it may only be used for places that are non-overlapping or identical.

The target place must have been flooded before calling this method.

Source

#### pub fn assign( &mut self, target: PlaceRef<'_>, result: ValueOrPlace<V>, map: &Map<'_>, )
where V: HasTop,

Helper method to interpret `target = result`.

Source

#### pub fn assign_discr( &mut self, target: PlaceRef<'_>, result: ValueOrPlace<V>, map: &Map<'_>, )
where V: HasTop,

Helper method for assignments to a discriminant.

Source

#### pub fn try_get(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>

Retrieve the value stored for a place, or `None` if it is not tracked.

Source

#### pub fn try_get_discr(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>

Retrieve the discriminant stored for a place, or `None` if it is not tracked.

Source

#### pub fn try_get_len(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>

Retrieve the slice length stored for a place, or `None` if it is not tracked.

Source

#### pub fn try_get_idx(&self, place: PlaceIndex, map: &Map<'_>) -> Option<V>

Retrieve the value stored for a place index, or `None` if it is not tracked.

Source

#### pub fn get(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ if the place is tracked and the state is unreachable.

Source

#### pub fn get_discr(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

Source

#### pub fn get_len(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

Source

#### pub fn get_idx(&self, place: PlaceIndex, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place index, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

## Trait Implementations§

Source§

### impl<V: Clone> Clone for State<V>

Source§

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

Returns a duplicate of the value. Read more
Source§

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

Performs copy-assignment from `source`. Read more
Source§

### impl<V: Debug> Debug for State<V>

Source§

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

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

### impl<V: JoinSemiLattice + Clone> JoinSemiLattice for State<V>

Source§

#### fn join(&mut self, other: &Self) -> bool

Computes the least upper bound of two elements, storing the result in `self` and returning `true` if `self` has changed. Read more
Source§

### impl<V: PartialEq> PartialEq for State<V>

Source§

#### fn eq(&self, other: &State<V>) -> 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<V: Eq> Eq for State<V>

Source§

### impl<V> StructuralPartialEq for State<V>

## Auto Trait Implementations§

§

### impl<V> DynSend for State<V>
where V: DynSend,

§

### impl<V> DynSync for State<V>
where V: DynSync,

§

### impl<V> Freeze for State<V>
where V: Freeze,

§

### impl<V> RefUnwindSafe for State<V>
where V: RefUnwindSafe,

§

### impl<V> Send for State<V>
where V: Send,

§

### impl<V> Sync for State<V>
where V: Sync,

§

### impl<V> Unpin for State<V>
where V: Unpin,

§

### impl<V> UnsafeUnpin for State<V>
where V: UnsafeUnpin,

§

### impl<V> UnwindSafe for State<V>
where V: UnwindSafe,

## Blanket Implementations§

Source§

### impl<T> Aligned for T

Source§

#### const ALIGN: Alignment

Alignment of `Self`.
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> AnyEq for T
where T: Any + PartialEq,

Source§

#### fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

#### fn as_any(&self) -> &(dyn Any + 'static)

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, R> CollectAndApply<T, R> for T

Source§

#### fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to `f(&iter.collect::<Vec<_>>())`.

Source§

#### type Output = R

Source§

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

Source§

#### fn __clone_box(&self, _: Private) -> *mut ()

Source§

### impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

#### fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

### impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

#### fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

### impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

#### fn equivalent(&self, key: &K) -> bool

Compare self to `key` and return `true` if they are equal.
Source§

### impl<T> From<T> for T

Source§

#### fn from(t: T) -> T

Returns the argument unchanged.

Source§

### impl<T> Instrument for T

Source§

#### fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided `Span`, returning an `Instrumented` wrapper. Read more
Source§

#### fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current `Span`, returning an `Instrumented` wrapper. Read more
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> IntoEither for T

Source§

#### fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left` is `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. Read more
Source§

#### fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. Read more
Source§

### impl<K> IntoQueryKey<K> for K

Source§

#### fn into_query_key(self) -> K

Argument conversion from `Self` to `K`. This should always be a very cheap conversion, e.g. `LocalDefId::to_def_id`.
Source§

### impl<T> MaybeResult<T> for T

Source§

#### type Error = !

Source§

#### fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

#### fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

Source§

### impl<T> Pointable for T

Source§

#### const ALIGN: usize

The alignment of pointer.
Source§

#### type Init = T

The type for initializers.
Source§

#### unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

#### unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

#### unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

#### unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, 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.
Source§

### impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

Source§

#### fn upcast(self, interner: I) -> U

Source§

### impl<I, T> UpcastFrom<I, T> for T

Source§

#### fn upcast_from(from: T, _tcx: I) -> T

Source§

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

Source§

#### fn vzip(self) -> V

Source§

### impl<T> WithSubscriber for T

Source§

#### fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more
Source§

#### fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more
Source§

### impl<T> ErasedDestructor for T
where T: 'static,

## Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.