Enum rustc::ty::Region [] [src]

pub enum Region {
    ReEarlyBound(EarlyBoundRegion),
    ReLateBound(DebruijnIndexBoundRegion),
    ReFree(FreeRegion),
    ReScope(CodeExtent),
    ReStatic,
    ReVar(RegionVid),
    ReSkolemized(SkolemizedRegionVidBoundRegion),
    ReEmpty,
    ReErased,
}
🔬 This is a nightly-only experimental API. (rustc_private)

Representation of regions.

Unlike types, most region variants are "fictitious", not concrete, regions. Among these, ReStatic, ReEmpty and ReScope are the only ones representing concrete regions.

Bound Regions

These are regions that are stored behind a binder and must be substituted with some concrete region before being used. There are 2 kind of bound regions: early-bound, which are bound in an item's Generics, and are substituted by a Substs, and late-bound, which are part of higher-ranked types (e.g. for<'a> fn(&'a ())) and are substituted by the likes of liberate_late_bound_regions. The distinction exists because higher-ranked lifetimes aren't supported in all places. See [1][2].

Unlike TyParam-s, bound regions are not supposed to exist "in the wild" outside their binder, e.g. in types passed to type inference, and should first be substituted (by skolemized regions, free regions, or region variables).

Skolemized and Free Regions

One often wants to work with bound regions without knowing their precise identity. For example, when checking a function, the lifetime of a borrow can end up being assigned to some region parameter. In these cases, it must be ensured that bounds on the region can't be accidentally assumed without being checked.

The process of doing that is called "skolemization". The bound regions are replaced by skolemized markers, which don't satisfy any relation not explicity provided.

There are 2 kinds of skolemized regions in rustc: ReFree and ReSkolemized. When checking an item's body, ReFree is supposed to be used. These also support explicit bounds: both the internally-stored scope, which the region is assumed to outlive, as well as other relations stored in the FreeRegionMap. Note that these relations aren't checked when you make_subregion (or eq_types), only by resolve_regions_and_report_errors.

When working with higher-ranked types, some region relations aren't yet known, so you can't just call resolve_regions_and_report_errors. ReSkolemized is designed for this purpose. In these contexts, there's also the risk that some inference variable laying around will get unified with your skolemized region: if you want to check whether for<'a> Foo<'_>: 'a, and you substitute your bound region 'a with a skolemized region '%a, the variable '_ would just be instantiated to the skolemized region '%a, which is wrong because the inference variable is supposed to satisfy the relation for every value of the skolemized region. To ensure that doesn't happen, you can use leak_check. This is more clearly explained by infer/higher_ranked/README.md.

[1] http://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/ [2] http://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/

Variants

🔬 This is a nightly-only experimental API. (rustc_private)
🔬 This is a nightly-only experimental API. (rustc_private)
🔬 This is a nightly-only experimental API. (rustc_private)

When checking a function body, the types of all arguments and so forth that refer to bound region parameters are modified to refer to free region parameters.

🔬 This is a nightly-only experimental API. (rustc_private)

A concrete region naming some statically determined extent (e.g. an expression or sequence of statements) within the current function.

🔬 This is a nightly-only experimental API. (rustc_private)

Static data that has an "infinite" lifetime. Top in the region lattice.

🔬 This is a nightly-only experimental API. (rustc_private)

A region variable. Should not exist after typeck.

🔬 This is a nightly-only experimental API. (rustc_private)

A skolemized region - basically the higher-ranked version of ReFree. Should not exist after typeck.

🔬 This is a nightly-only experimental API. (rustc_private)

Empty lifetime is for data that is never accessed. Bottom in the region lattice. We treat ReEmpty somewhat specially; at least right now, we do not generate instances of it during the GLB computations, but rather generate an error instead. This is to improve error messages. The only way to get an instance of ReEmpty is to have a region variable with no constraints.

🔬 This is a nightly-only experimental API. (rustc_private)

Erased region, used by trait selection, in MIR and during trans.

Methods

impl Region
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

Returns the depth of self from the (1-based) binding level depth

🔬 This is a nightly-only experimental API. (rustc_private)

Trait Implementations

impl<'tcx> Relate<'tcx> for &'tcx Region
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

impl<'a, 'tcx> Lift<'tcx> for &'a Region
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

impl<'tcx> TypeFoldable<'tcx> for &'tcx Region
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

Indicates whether this value references only 'global' types/lifetimes that are the same regardless of what fn we are in. This is used for caching. Errs on the side of returning false. Read more

impl Clone for Region
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Region
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Region
[src]

impl Hash for Region
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl Copy for Region
[src]

impl Encodable for Region
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

deprecated in favor of rustc-serialize on crates.io

impl Decodable for Region
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

deprecated in favor of rustc-serialize on crates.io

impl<'tcx> UseSpecializedDecodable for &'tcx Region
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

deprecated in favor of rustc-serialize on crates.io

Defaults to returning an error (see SpecializationError).

impl Debug for Region
[src]

Formats the value using the given formatter.

impl Display for Region
[src]

Formats the value using the given formatter. Read more