Skip to main content

RegionInferenceContextInner

Struct RegionInferenceContextInner 

Source
pub struct RegionInferenceContextInner<'tcx> {
    pub(crate) definitions: Frozen<IndexVec<RegionVid, RegionDefinition<'tcx>>>,
    pub(super) liveness_constraints: LivenessValues,
    pub(super) constraints: Frozen<OutlivesConstraintSet<'tcx>>,
    pub(super) constraint_graph: Frozen<ConstraintGraph<Normal>>,
    pub(super) constraint_sccs: Sccs<RegionVid, ConstraintSccIndex>,
    pub(super) scc_annotations: IndexVec<ConstraintSccIndex, RegionTracker>,
    pub(super) universe_causes: FxIndexMap<UniverseIndex, UniverseInfo<'tcx>>,
    pub(super) scc_values: RegionValues<'tcx, ConstraintSccIndex>,
    pub(super) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
}
Expand description

Contains the data for RegionInferenceContext and UnsolvedRegionInferenceContext.

Fields§

§definitions: Frozen<IndexVec<RegionVid, RegionDefinition<'tcx>>>

Contains the definition for every region variable. Region variables are identified by their index (RegionVid). The definition contains information about where the region came from as well as its final inferred value.

§liveness_constraints: LivenessValues

The liveness constraints added to each region. For most regions, these start out empty and steadily grow, though for each universally quantified region R they start out containing the entire CFG and end(R).

§constraints: Frozen<OutlivesConstraintSet<'tcx>>

The outlives constraints computed by the type-check.

§constraint_graph: Frozen<ConstraintGraph<Normal>>

The constraint-set, but in graph form, making it easy to traverse the constraints adjacent to a particular region. Used to construct the SCC (see constraint_sccs) and for error reporting.

§constraint_sccs: Sccs<RegionVid, ConstraintSccIndex>

The SCC computed from constraints and the constraint graph. We have an edge from SCC A to SCC B if A: B. Used to compute the values of each region.

§scc_annotations: IndexVec<ConstraintSccIndex, RegionTracker>§universe_causes: FxIndexMap<UniverseIndex, UniverseInfo<'tcx>>

Map universe indexes to information on why we created it.

§scc_values: RegionValues<'tcx, ConstraintSccIndex>

The final inferred values of the region variables; we compute one value per SCC. To get the value for any given region, you first find which scc it is a part of.

§universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>

Information about how the universally quantified regions in scope on this function relate to one another.

Implementations§

Source§

impl<'tcx> RegionInferenceContextInner<'tcx>

Source

pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> + 'tcx

Returns an iterator over all the region indices.

Source

pub(crate) fn to_region_vid(&self, r: Region<'tcx>) -> RegionVid

Given a universal region in scope on the MIR, returns the corresponding index.

Panics if r is not a registered universal region, most notably if it is a placeholder. Handling placeholders requires access to the MirTypeckRegionConstraints.

Source

pub(crate) fn outlives_constraints( &self, ) -> impl Iterator<Item = OutlivesConstraint<'tcx>>

Returns an iterator over all the outlives constraints.

Source

pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_>)

Adds annotations for #[rustc_regions]; see UniversalRegions::annotate.

Source

pub(crate) fn region_contains_point(&self, r: RegionVid, p: Location) -> bool

Returns true if the region r contains the point p.

Panics if called before solve() executes,

Source

pub(crate) fn first_non_contained_inclusive( &self, r: RegionVid, block: BasicBlock, start: usize, end: usize, ) -> Option<usize>

Returns the lowest statement index in start..=end which is not contained by r.

Panics if called before solve() executes.

Source

pub(crate) fn region_value_str(&self, r: RegionVid) -> String

Returns access to the value of r for debugging purposes.

Source

pub(crate) fn placeholders_contained_in( &self, r: RegionVid, ) -> impl Iterator<Item = PlaceholderRegion<'tcx>>

Source

pub(crate) fn approx_universal_upper_bound(&self, r: RegionVid) -> RegionVid

Like universal_upper_bound, but returns an approximation more suitable for diagnostics. If r contains multiple disjoint universal regions (e.g. ’a and ’b in fn foo<'a, 'b> { ... }, we pick the lower-numbered region. This corresponds to picking named regions over unnamed regions (e.g. picking early-bound regions over a closure late-bound region).

This means that the returned value may not be a true upper bound, since only ’static is known to outlive disjoint universal regions. Therefore, this method should only be used in diagnostic code, where displaying some named universal region is better than falling back to ’static.

Source

pub(super) fn max_nameable_universe( &self, scc: ConstraintSccIndex, ) -> UniverseIndex

The largest universe of any region nameable from this SCC.

Source

pub(crate) fn constraint_path_between_regions( &self, from_region: RegionVid, to_region: RegionVid, ) -> Option<Vec<OutlivesConstraint<'tcx>>>

Source

pub(crate) fn constraint_path_to( &self, from_region: RegionVid, target_test: impl Fn(RegionVid) -> bool, include_placeholder_static: bool, ) -> Option<(Vec<OutlivesConstraint<'tcx>>, RegionVid)>

Walks the graph of constraints (where 'a: 'b is considered an edge 'a -> 'b) to find a path from from_region to to_region.

Returns: a series of constraints as well as the region R that passed the target test. If include_static_outlives_all is true, then the synthetic outlives constraints 'static -> a for every region a are considered in the search, otherwise they are ignored.

Source

fn find_constraint_path_between_regions_inner( &self, ignore_opaque_type_constraints: bool, from_region: RegionVid, target_test: impl Fn(RegionVid) -> bool, include_placeholder_static: bool, ) -> Option<(Vec<OutlivesConstraint<'tcx>>, RegionVid)>

The constraints we get from equating the hidden type of each use of an opaque with its final hidden type may end up getting preferred over other, potentially longer constraint paths.

Given that we compute the final hidden type by relying on this existing constraint path, this can easily end up hiding the actual reason for why we require these regions to be equal.

To handle this, we first look at the path while ignoring these constraints and then retry while considering them. This is not perfect, as the from_region may have already been partially related to its argument region, so while we rely on a member constraint to get a complete path, the most relevant step of that path already existed before then.

Source

pub(crate) fn find_sub_region_live_at( &self, fr1: RegionVid, location: Location, ) -> RegionVid

Finds some region R such that fr1: R and R is live at location.

Source

pub(crate) fn region_definition(&self, r: RegionVid) -> &RegionDefinition<'tcx>

Get the region definition of r.

Source

pub(crate) fn upper_bound_in_region_scc( &self, r: RegionVid, upper: RegionVid, ) -> bool

Check if the SCC of r contains upper, a free region.

Source

pub(crate) fn universal_regions(&self) -> &UniversalRegions<'tcx>

Source

pub(crate) fn best_blame_constraint( &self, from_region: RegionVid, from_region_origin: NllRegionVariableOrigin<'tcx>, to_region: RegionVid, ) -> BestBlame<'tcx>

Tries to find the best constraint to blame for the fact that R: from_region, where R is some region that meets target_test. This works by following the constraint graph, creating a constraint path that forces R to outlive from_region, and then finding the best choices within that path to blame.

Source

pub(crate) fn universe_info( &self, universe: UniverseIndex, ) -> UniverseInfo<'tcx>

Source

pub(crate) fn find_loop_terminator_location( &self, r: RegionVid, body: &Body<'_>, ) -> Option<Location>

Tries to find the terminator of the loop in which the region ‘r’ resides. Returns the location of the terminator if found.

Source

pub(crate) fn constraint_sccs(&self) -> &Sccs<RegionVid, ConstraintSccIndex>

Access to the SCC constraint graph. This can be used to quickly under-approximate the regions which are equal to each other and their relative orderings.

Source

pub(crate) fn liveness_constraints(&self) -> &LivenessValues

Source

pub(crate) fn is_loan_live_at( &self, loan_idx: BorrowIndex, location: Location, ) -> bool

Returns whether the loan_idx is live at the given location: whether its issuing region is contained within the type of a variable that is live at this point. Note: for now, the sets of live loans is only available when using -Zpolonius=next.

Auto Trait Implementations§

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> 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, 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> ErasedDestructor for T
where T: 'static,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

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