pub struct UniverseIndex(_);
🔬 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?
"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. But when you enter into
some subuniverse, then it may add names that are only visible
within that subtree (but it can still name the names of its
ancestor universes).
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 a subuniverse 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 subuniverse U2 of U1, because we can name it
inside the fn type but not outside.
Universes are related to skolemization -- which is a way of
doing 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 skolemized 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 skolemized type -- an
idealized representative of "types in general" that we use for
checking generic functions.
🔬 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?
The root universe, where things that the user defined are
visible.
🔬 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 "subuniverse" corresponds to being inside a forall
quantifier.
So, for example, suppose we have this type in universe U
:
for<'a> fn(&'a u32)
Once we "enter" into this for<'a>
quantifier, we are in a
subuniverse of U
-- in this new universe, we can name the
region 'a
, but that region was not nameable from U
because
it was not in scope there.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the minimum of two values. Read more
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more