pub struct Map {
    locals: IndexVec<Local, Option<PlaceIndex>>,
    projections: FxHashMap<(PlaceIndex, TrackElem), PlaceIndex>,
    places: IndexVec<PlaceIndex, PlaceInfo>,
    value_count: usize,
}
Expand description

Partial mapping from Place to PlaceIndex, where some places also have a ValueIndex.

This data structure essentially maintains a tree of places and their projections. Some additional bookkeeping is done, to speed up traversal over this tree:

  • For iteration, every PlaceInfo contains an intrusive linked list of its children.
  • To directly get the child for a specific projection, there is a projections map.

Fields§

§locals: IndexVec<Local, Option<PlaceIndex>>§projections: FxHashMap<(PlaceIndex, TrackElem), PlaceIndex>§places: IndexVec<PlaceIndex, PlaceInfo>§value_count: usize

Implementations§

source§

impl Map

source

fn new() -> Self

source

pub fn from_filter<'tcx>(
    tcx: TyCtxt<'tcx>,
    body: &Body<'tcx>,
    filter: impl FnMut(Ty<'tcx>) -> bool
) -> Self

Returns a map that only tracks places whose type passes the filter.

This is currently the only way to create a Map. The way in which the tracked places are chosen is an implementation detail and may not be relied upon (other than that their type passes the filter).

source

fn register_with_filter<'tcx>(
    &mut self,
    tcx: TyCtxt<'tcx>,
    body: &Body<'tcx>,
    filter: impl FnMut(Ty<'tcx>) -> bool,
    exclude: &IndexVec<Local, bool>
)

Register all non-excluded places that pass the filter.

source

fn register_with_filter_rec<'tcx>(
    &mut self,
    tcx: TyCtxt<'tcx>,
    local: Local,
    projection: &mut Vec<PlaceElem<'tcx>>,
    ty: Ty<'tcx>,
    filter: &mut impl FnMut(Ty<'tcx>) -> bool
)

Potentially register the (local, projection) place and its fields, recursively.

Invariant: The projection must only contain fields.

source

fn make_place<'tcx>(
    &mut self,
    local: Local,
    projection: &[PlaceElem<'tcx>]
) -> Result<PlaceIndex, ()>

Tries to add the place to the map, without allocating a value slot.

Can fail if the projection contains non-trackable elements.

source

pub fn tracked_places(&self) -> usize

Returns the number of tracked places, i.e., those for which a value can be stored.

source

pub fn apply(&self, place: PlaceIndex, elem: TrackElem) -> Option<PlaceIndex>

Applies a single projection element, yielding the corresponding child.

source

pub fn find(&self, place: PlaceRef<'_>) -> Option<PlaceIndex>

Locates the given place, if it exists in the tree.

source

pub fn children(
    &self,
    parent: PlaceIndex
) -> impl Iterator<Item = PlaceIndex> + '_

Iterate over all direct children.

source

pub fn preorder_invoke(&self, root: PlaceIndex, f: &mut impl FnMut(PlaceIndex))

Invoke a function on the given place and all descendants.

Trait Implementations§

source§

impl Debug for Map

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Map

§

impl Send for Map

§

impl Sync for Map

§

impl Unpin for Map

§

impl UnwindSafe for Map

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.

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: 88 bytes