Enum rustc::ty::RegionKind [−][src]
pub enum RegionKind { ReEarlyBound(EarlyBoundRegion), ReLateBound(DebruijnIndex, BoundRegion), ReFree(FreeRegion), ReScope(Scope), ReStatic, ReVar(RegionVid), ReSkolemized(UniverseIndex, BoundRegion), ReEmpty, ReErased, ReClosureBound(RegionVid), ReCanonical(CanonicalVar), }
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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.
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 explicitly 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 the rustc guide.
Variants
ReEarlyBound(EarlyBoundRegion)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
ReLateBound(DebruijnIndex, BoundRegion)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
ReFree(FreeRegion)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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.
ReScope(Scope)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
A concrete region naming some statically determined scope (e.g. an expression or sequence of statements) within the current function.
ReStatic
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Static data that has an "infinite" lifetime. Top in the region lattice.
ReVar(RegionVid)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
A region variable. Should not exist after typeck.
ReSkolemized(UniverseIndex, BoundRegion)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
A skolemized region - basically the higher-ranked version of ReFree. Should not exist after typeck.
ReEmpty
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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.
ReErased
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Erased region, used by trait selection, in MIR and during codegen.
ReClosureBound(RegionVid)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
These are regions bound in the "defining type" for a
closure. They are used ONLY as part of the
ClosureRegionRequirements
that are produced by MIR borrowck.
See ClosureRegionRequirements
for more details.
ReCanonical(CanonicalVar)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Canonicalized region, used only when preparing a trait query.
Methods
impl RegionKind
[src]
impl RegionKind
Region utilities
pub fn is_late_bound(&self) -> bool
[src]
pub fn is_late_bound(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn bound_at_or_above_binder(&self, index: DebruijnIndex) -> bool
[src]
pub fn bound_at_or_above_binder(&self, index: DebruijnIndex) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn shifted_out_to_binder(&self, to_binder: DebruijnIndex) -> RegionKind
[src]
pub fn shifted_out_to_binder(&self, to_binder: DebruijnIndex) -> RegionKind
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Adjusts any Debruijn Indices so as to make to_binder
the
innermost binder. That is, if we have something bound at to_binder
,
it will now be bound at INNERMOST. This is an appropriate thing to do
when moving a region out from inside binders:
for<'a> fn(for<'b> for<'c> fn(&'a u32), _) // Binder: D3 D2 D1 ^^
Here, the region 'a
would have the debruijn index D3,
because it is the bound 3 binders out. However, if we wanted
to refer to that region 'a
in the second argument (the _
),
those two binders would not be in scope. In that case, we
might invoke shift_out_to_binder(D3)
. This would adjust the
debruijn index of 'a
to D1 (the innermost binder).
If we invoke shift_out_to_binder
and the region is in fact
bound by one of the binders we are shifting out of, that is an
error (and should fail an assertion failure).
pub fn keep_in_local_tcx(&self) -> bool
[src]
pub fn keep_in_local_tcx(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn type_flags(&self) -> TypeFlags
[src]
pub fn type_flags(&self) -> TypeFlags
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn free_region_binding_scope(&self, tcx: TyCtxt) -> DefId
[src]
pub fn free_region_binding_scope(&self, tcx: TyCtxt) -> DefId
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given an early-bound or free region, returns the def-id where it was bound. For example, consider the regions in this snippet of code:
impl<'a> Foo { ^^ -- early bound, declared on an impl fn bar<'b, 'c>(x: &self, y: &'b u32, z: &'c u64) where 'static: 'c ^^ ^^ ^ anonymous, late-bound | early-bound, appears in where-clauses late-bound, appears only in fn args {..} }
Here, free_region_binding_scope('a)
would return the def-id
of the impl, and for all the other highlighted regions, it
would return the def-id of the function. In other cases (not shown), this
function might return the def-id of a closure.
Trait Implementations
impl<'a> HashStable<StableHashingContext<'a>> for RegionKind
[src]
impl<'a> HashStable<StableHashingContext<'a>> for RegionKind
fn hash_stable<W: StableHasherResult>(
&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>
)
[src]
fn hash_stable<W: StableHasherResult>(
&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>
)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl<'tcx> Borrow<RegionKind> for Interned<'tcx, RegionKind>
[src]
impl<'tcx> Borrow<RegionKind> for Interned<'tcx, RegionKind>
fn borrow<'a>(&'a self) -> &'a RegionKind
[src]
fn borrow<'a>(&'a self) -> &'a RegionKind
Immutably borrows from an owned value. Read more
impl Clone for RegionKind
[src]
impl Clone for RegionKind
fn clone(&self) -> RegionKind
[src]
fn clone(&self) -> RegionKind
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for RegionKind
[src]
impl PartialEq for RegionKind
fn eq(&self, other: &RegionKind) -> bool
[src]
fn eq(&self, other: &RegionKind) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &RegionKind) -> bool
[src]
fn ne(&self, other: &RegionKind) -> bool
This method tests for !=
.
impl Eq for RegionKind
[src]
impl Eq for RegionKind
fn assert_receiver_is_total_eq(&self)
[src]
fn assert_receiver_is_total_eq(&self)
impl Hash for RegionKind
[src]
impl Hash for RegionKind
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Copy for RegionKind
[src]
impl Copy for RegionKind
impl Encodable for RegionKind
[src]
impl Encodable for RegionKind
fn encode<__S: Encoder>(&self, s: &mut __S) -> Result<(), __S::Error>
[src]
fn encode<__S: Encoder>(&self, s: &mut __S) -> Result<(), __S::Error>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl Decodable for RegionKind
[src]
impl Decodable for RegionKind
fn decode<__D: Decoder>(d: &mut __D) -> Result<RegionKind, __D::Error>
[src]
fn decode<__D: Decoder>(d: &mut __D) -> Result<RegionKind, __D::Error>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl PartialOrd for RegionKind
[src]
impl PartialOrd for RegionKind
fn partial_cmp(&self, other: &RegionKind) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &RegionKind) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &RegionKind) -> bool
[src]
fn lt(&self, other: &RegionKind) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &RegionKind) -> bool
[src]
fn le(&self, other: &RegionKind) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &RegionKind) -> bool
[src]
fn gt(&self, other: &RegionKind) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &RegionKind) -> bool
[src]
fn ge(&self, other: &RegionKind) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for RegionKind
[src]
impl Ord for RegionKind
fn cmp(&self, other: &RegionKind) -> Ordering
[src]
fn cmp(&self, other: &RegionKind) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Print for RegionKind
[src]
impl Print for RegionKind
fn print<F: Write>(&self, f: &mut F, cx: &mut PrintContext) -> Result
[src]
fn print<F: Write>(&self, f: &mut F, cx: &mut PrintContext) -> Result
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn print_to_string(&self, cx: &mut PrintContext) -> String
[src]
fn print_to_string(&self, cx: &mut PrintContext) -> String
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn print_display<F: Write>(&self, f: &mut F, cx: &mut PrintContext) -> Result
[src]
fn print_display<F: Write>(&self, f: &mut F, cx: &mut PrintContext) -> Result
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn print_display_to_string(&self, cx: &mut PrintContext) -> String
[src]
fn print_display_to_string(&self, cx: &mut PrintContext) -> String
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn print_debug<F: Write>(&self, f: &mut F, cx: &mut PrintContext) -> Result
[src]
fn print_debug<F: Write>(&self, f: &mut F, cx: &mut PrintContext) -> Result
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn print_debug_to_string(&self, cx: &mut PrintContext) -> String
[src]
fn print_debug_to_string(&self, cx: &mut PrintContext) -> String
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl Display for RegionKind
[src]
impl Display for RegionKind
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Debug for RegionKind
[src]
impl Debug for RegionKind
Auto Trait Implementations
impl !Send for RegionKind
impl !Send for RegionKind
impl !Sync for RegionKind
impl !Sync for RegionKind