Place 2.0 current PR status
  • Right now we have a tree-like structure, which is not the most convenient and can be a efficiency hazard:

/// A path to a value; something that can be evaluated without
/// changing or disturbing program state.
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub enum Place<'tcx> {
    /// local variable
    Local(Local),

    /// static or static mut variable
    Static(Box<Static<'tcx>>),

    /// Constant code promoted to an injected static
    Promoted(Box<(Promoted, Ty<'tcx>)>),

    /// projection out of a place (access a field, deref a pointer, etc)
    Projection(Box<PlaceProjection<'tcx>>),
}

  • Proposed structure is like this (inspired by something @eddyb said, and I imagine that they will have suggestions too):

struct Place<'tcx> {
    base: PlaceBase<'tcx>,
    elem: &'tcx Slice<ProjectionElem<'tcx>>,
}

enum PlaceBase<'tcx> {
    /// local variable
    Local(Local),

    /// static or static mut variable
    Static(Box<Static<'tcx>>),

    /// Constant code promoted to an injected static
    Promoted(Box<(Promoted, Ty<'tcx>)>),
}

  • In other words, instead of representing a.b.c as .c → .b → .a we would represent it as (a, [b, c]) (here, [b, c] would be an interned slice).
  • The advantages of this setup:
  • Place is now Copy, which is always nice
  • You can figure out very quickly that a.b.c is disjoint from d.e.f

  • @csmoe began the work towards these new setup and @spastorino took over at some point.
  • We have the new structure as a side thing of Place and it’s called NeoPlace, the structures were added and a lot of functions were ported by @csmoe
  • @spastorino completed the missing functions and fixed some bugs
  • Then got rid of NeoPlaceTree which was a structured that was mimicking  Place but we could just use Place