Skip to main content

## AllocState

# Type Alias AllocState

Source

    pub type AllocState = Tree;

## Aliased Type§

    pub struct AllocState {
        pub(super) tag_mapping: UniKeyMap<BorTag>,
        pub(super) nodes: UniValMap<Node>,
        pub(super) locations: DedupRangeMap<LocationTree>,
        pub(super) roots: SmallVec<[UniIndex; 2]>,
    }

## Fields§

§`tag_mapping: UniKeyMap<BorTag>`

Mapping from tags to keys. The key obtained can then be used in any of the `UniValMap` relative to this allocation, i.e. `nodes`, `LocationTree::perms` and `LocationTree::exposed_cache` of the same `Tree`. The parent-child relationship in `Node` is encoded in terms of these same keys, so traversing the entire tree needs exactly one access to `tag_mapping`.

§`nodes: UniValMap<Node>`

All nodes of this tree.

§`locations: DedupRangeMap<LocationTree>`

Associates with each location its state and wildcard access tracking.

§`roots: SmallVec<[UniIndex; 2]>`

Contains both the root of the main tree as well as the roots of the wildcard subtrees.

If we reborrow a reference which has wildcard provenance, then we do not know where in the tree to attach them. Instead we create a new additional tree for this allocation with this new reference as a root. We call this additional tree a wildcard subtree.

The actual structure should be a single tree but with wildcard provenance we approximate this with this ordered set of trees. Each wildcard subtree is the direct child of some exposed tag (that is smaller than the root), but we do not know which. This also means that it can only be the child of a tree that comes before it in the vec ensuring we don’t have any cycles in our approximated tree.

Sorted according to `BorTag` from low to high. This also means the main root is `root[0]`.

Has array size 2 because that still ensures the minimum size for SmallVec.

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