Struct rustc_middle::ty::UniverseIndex
source · [−]pub struct UniverseIndex {
pub(crate) private: u32,
}
Expand description
“Universes” are used during type- and trait-checking in the
presence of for<..>
binders to control what sets of names are
visible. Universes are arranged into a tree: the root universe
contains names that are always visible. Each child then adds a new
set of names that are visible, in addition to those of its parent.
We say that the child universe “extends” the parent universe with
new names.
To make this more concrete, consider this program:
struct Foo { }
fn bar<T>(x: T) {
let y: for<'a> fn(&'a u8, Foo) = ...;
}
The struct name Foo
is in the root universe U0. But the type
parameter T
, introduced on bar
, is in an extended universe U1
– i.e., within bar
, we can name both T
and Foo
, but outside
of bar
, we cannot name T
. Then, within the type of y
, the
region 'a
is in a universe U2 that extends U1, because we can
name it inside the fn type but not outside.
Universes are used to do type- and trait-checking around these
“forall” binders (also called universal quantification). The
idea is that when, in the body of bar
, we refer to T
as a
type, we aren’t referring to any type in particular, but rather a
kind of “fresh” type that is distinct from all other types we have
actually declared. This is called a placeholder type, and we
use universes to talk about this. In other words, a type name in
universe 0 always corresponds to some “ground” type that the user
declared, but a type name in a non-zero universe is a placeholder
type – an idealized representative of “types in general” that we
use for checking generic functions.
Fields
private: u32
Trait Implementations
sourceimpl<'tcx> Lift<'tcx> for UniverseIndex
impl<'tcx> Lift<'tcx> for UniverseIndex
type Lifted = UniverseIndex
fn lift_to_tcx(self, _: TyCtxt<'tcx>) -> Option<Self>
sourceimpl<'tcx> TypeFoldable<'tcx> for UniverseIndex
impl<'tcx> TypeFoldable<'tcx> for UniverseIndex
sourcefn try_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
_: &mut F
) -> Result<UniverseIndex, F::Error>
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
_: &mut F
) -> Result<UniverseIndex, F::Error>
sourcefn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self
fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self
try_fold_with
for use with infallible
folders. Do not override this method, to ensure coherence with
try_fold_with
. Read moresourceimpl<'tcx> TypeVisitable<'tcx> for UniverseIndex
impl<'tcx> TypeVisitable<'tcx> for UniverseIndex
sourcefn visit_with<F: TypeVisitor<'tcx>>(&self, _: &mut F) -> ControlFlow<F::BreakTy>
fn visit_with<F: TypeVisitor<'tcx>>(&self, _: &mut F) -> ControlFlow<F::BreakTy>
sourcefn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
true
if self
has any late-bound regions that are either
bound by binder
or bound by some binder outside of binder
.
If binder
is ty::INNERMOST
, this indicates whether
there are any late-bound regions that appear free. Read moresourcefn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read morefn has_escaping_bound_vars(&self) -> bool
fn has_type_flags(&self, flags: TypeFlags) -> bool
fn has_projections(&self) -> bool
fn has_opaque_types(&self) -> bool
fn references_error(&self) -> bool
fn error_reported(&self) -> Option<ErrorGuaranteed>
fn has_param_types_or_consts(&self) -> bool
fn has_infer_regions(&self) -> bool
fn has_infer_types(&self) -> bool
fn has_infer_types_or_consts(&self) -> bool
fn needs_infer(&self) -> bool
fn has_placeholders(&self) -> bool
fn needs_subst(&self) -> bool
sourcefn has_free_regions(&self) -> bool
fn has_free_regions(&self) -> bool
fn has_erased_regions(&self) -> bool
sourcefn has_erasable_regions(&self) -> bool
fn has_erasable_regions(&self) -> bool
sourcefn is_global(&self) -> bool
fn is_global(&self) -> bool
sourcefn has_late_bound_regions(&self) -> bool
fn has_late_bound_regions(&self) -> bool
sourcefn still_further_specializable(&self) -> bool
fn still_further_specializable(&self) -> bool
impl
specialization. Read moreAuto Trait Implementations
impl RefUnwindSafe for UniverseIndex
impl Send for UniverseIndex
impl Sync for UniverseIndex
impl Unpin for UniverseIndex
impl UnwindSafe for UniverseIndex
Blanket Implementations
sourceimpl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter(
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = T>
) -> &'a mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
default fn fingerprint_style() -> FingerprintStyle
sourcedefault fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_debug_str(&self, Ctxt) -> String
sourcedefault fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
default fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresourceimpl<T, R> InternIteratorElement<T, R> for T
impl<T, R> InternIteratorElement<T, R> for T
type Output = R
fn intern_with<I, F>(iter: I, f: F) -> <T as InternIteratorElement<T, R>>::Outputwhere
I: Iterator<Item = T>,
F: FnOnce(&[T]) -> R,
sourceimpl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
sourceimpl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
impl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
default fn from_cycle_error(tcx: CTX) -> T
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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: 4 bytes