[][src]Struct rustc::mir::ClosureRegionRequirements

pub struct ClosureRegionRequirements<'tcx> {
    pub num_external_vids: usize,
    pub outlives_requirements: Vec<ClosureOutlivesRequirement<'tcx>>,
}
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

After we borrow check a closure, we are left with various requirements that we have inferred between the free regions that appear in the closure's signature or on its field types. These requirements are then verified and proved by the closure's creating function. This struct encodes those requirements.

The requirements are listed as being between various RegionVid. The 0th region refers to 'static; subsequent region vids refer to the free regions that appear in the closure (or generator's) type, in order of appearance. (This numbering is actually defined by the UniversalRegions struct in the NLL region checker. See for example UniversalRegions::closure_mapping.) Note that we treat the free regions in the closure's type "as if" they were erased, so their precise identity is not important, only their position.

Example: If type check produces a closure with the closure substs:

ClosureSubsts = [
    i8,                                  // the "closure kind"
    for<'x> fn(&'a &'x u32) -> &'x u32,  // the "closure signature"
    &'a String,                          // some upvar
]

here, there is one unique free region ('a) but it appears twice. We would "renumber" each occurrence to a unique vid, as follows:

ClosureSubsts = [
    i8,                                  // the "closure kind"
    for<'x> fn(&'1 &'x u32) -> &'x u32,  // the "closure signature"
    &'2 String,                          // some upvar
]

Now the code might impose a requirement like '1: '2. When an instance of the closure is created, the corresponding free regions can be extracted from its type and constrained to have the given outlives relationship.

In some cases, we have to record outlives requirements between types and regions as well. In that case, if those types include any regions, those regions are recorded as ReClosureBound instances assigned one of these same indices. Those regions will be substituted away by the creator. We use ReClosureBound in that case because the regions must be allocated in the global TyCtxt, and hence we cannot use ReVar (which is what we use internally within the rest of the NLL code).

Fields

num_external_vids: usize
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

The number of external regions defined on the closure. In our example above, it would be 3 -- one for 'static, then '1 and '2. This is just used for a sanity check later on, to make sure that the number of regions we see at the callsite matches.

outlives_requirements: Vec<ClosureOutlivesRequirement<'tcx>>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Requirements between the various free regions defined in indices.

Trait Implementations

impl<'tcx> Clone for ClosureRegionRequirements<'tcx>[src]

impl<'tcx> Debug for ClosureRegionRequirements<'tcx>[src]

impl<'tcx> Decodable for ClosureRegionRequirements<'tcx>[src]

impl<'tcx> Encodable for ClosureRegionRequirements<'tcx>[src]

impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for ClosureRegionRequirements<'tcx>[src]

Auto Trait Implementations

impl<'tcx> !RefUnwindSafe for ClosureRegionRequirements<'tcx>

impl<'tcx> !Send for ClosureRegionRequirements<'tcx>

impl<'tcx> !Sync for ClosureRegionRequirements<'tcx>

impl<'tcx> Unpin for ClosureRegionRequirements<'tcx>

impl<'tcx> !UnwindSafe for ClosureRegionRequirements<'tcx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Decodable for T where
    T: UseSpecializedDecodable
[src]

impl<T> Encodable for T where
    T: UseSpecializedEncodable + ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<E> SpecializationError for E[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]