Struct rustc_middle::ty::list::List [−][src]
#[repr(C)]pub struct List<T> {
len: usize,
data: [T; 0],
opaque: OpaqueListContents,
}
Expand description
A wrapper for slices with the additional invariant that the slice is interned and no other slice with the same contents can exist in the same context. This means we can use pointer for both equality comparisons and hashing.
Unlike slices, the types contained in List
are expected to be Copy
and iterating over a List
returns T
instead of a reference.
Note: Slice
was already taken by the Ty
.
Fields
len: usize
data: [T; 0]
opaque: OpaqueListContents
Implementations
Interpret these substitutions as the substitutions of a closure type.
Closure substitutions have a particular structure controlled by the
compiler that encodes information like the signature and closure kind;
see ty::ClosureSubsts
struct for more comments.
Interpret these substitutions as the substitutions of a generator type.
Generator substitutions have a particular structure controlled by the
compiler that encodes information like the signature and generator kind;
see ty::GeneratorSubsts
struct for more comments.
Creates an InternalSubsts
that maps each generic parameter to itself.
pub fn for_item<F>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F
) -> SubstsRef<'tcx> where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn for_item<F>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F
) -> SubstsRef<'tcx> where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
Creates an InternalSubsts
for generic parameter definitions,
by calling closures to obtain each kind.
The closures get to observe the InternalSubsts
as they’re
being built, which can be used to correctly
substitute defaults of generic parameters.
pub fn extend_to<F>(
&self,
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F
) -> SubstsRef<'tcx> where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn fill_item<F>(
substs: &mut SmallVec<[GenericArg<'tcx>; 8]>,
tcx: TyCtxt<'tcx>,
defs: &Generics,
mk_kind: &mut F
) where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn fill_single<F>(
substs: &mut SmallVec<[GenericArg<'tcx>; 8]>,
defs: &Generics,
mk_kind: &mut F
) where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn non_erasable_generics(
&'a self
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'a
Transform from substitutions for a child of source_ancestor
(e.g., a trait or impl) to substitutions for the same child
in a different item, with target_substs
as the base for
the target impl/trait, with the source child-specific
parameters (e.g., method parameters) on top of that base.
For example given:
trait X<S> { fn f<T>(); }
impl<U> X<U> for U { fn f<V>() {} }
- If
self
is[Self, S, T]
: the identity substs off
in the trait. - If
source_ancestor
is the def_id of the trait. - If
target_substs
is[U]
, the substs for the impl. - Then we will return
[U, T]
, the subst forf
in the impl that are needed for it to match the trait.
Returns the “principal DefId
” of this set of existential predicates.
A Rust trait object type consists (in addition to a lifetime bound) of a set of trait bounds, which are separated into any number of auto-trait bounds, and at most one non-auto-trait bound. The non-auto-trait bound is called the “principal” of the trait object.
Only the principal can have methods or type parameters (because auto traits can have neither of them). This is important, because it means the auto traits can be treated as an unordered set (methods would force an order for the vtable, while relating traits with type parameters without knowing the order to relate them in is a rather non-trivial task).
For example, in the trait object dyn fmt::Debug + Sync
, the
principal bound is Some(fmt::Debug)
, while the auto-trait bounds
are the set {Sync}
.
It is also possible to have a “trivial” trait object that
consists only of auto traits, with no principal - for example,
dyn Send + Sync
. In that case, the set of auto-trait bounds
is {Send, Sync}
, while there is no principal. These trait objects
have a “trivial” vtable consisting of just the size, alignment,
and destructor.
pub fn projection_bounds<'a>(
&'a self
) -> impl Iterator<Item = Binder<'tcx, ExistentialProjection<'tcx>>> + 'a
Trait Implementations
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx List<T> where
T: HashStable<StableHashingContext<'a>>,
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx List<T> where
T: HashStable<StableHashingContext<'a>>,
type Lifted = &'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>
type Lifted = &'tcx List<CanonicalVarInfo<'tcx>>
type Lifted = &'tcx List<ProjectionKind>
type Lifted = &'tcx List<BoundVariableKind>
type Lifted = &'tcx List<GenericArg<'tcx>>
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
Most likely the value you want to use here is the following, unless
your Pointee type is unsized (e.g., ty::List<T>
in rustc) in which
case you’ll need to manually figure out what the right type to pass to
align_of is. Read more
Safety Read more
This provides a reference to the Pointer
itself, rather than the
Deref::Target
. It is used for cases where we want to call methods that
may be implement differently for the Pointer than the Pointee (e.g.,
Rc::clone
vs cloning the inner value). Read more
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for List<Binder<'tcx, ExistentialPredicate<'tcx>>>
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for List<Binder<'tcx, ExistentialPredicate<'tcx>>>
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
a: Self,
b: Self
) -> RelateResult<'tcx, Self>
impl<'a, 'tcx, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx List<T> where
T: HashStable<StableHashingContext<'a>>,
impl<'a, 'tcx, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx List<T> where
T: HashStable<StableHashingContext<'a>>,
type KeyType = Fingerprint
Returns 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 more
Returns true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read more
“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
True if there are any un-erased free regions.
Indicates whether this value definitely references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
True if there are any late-bound regions
Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
Returns 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 more
Returns true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read more
“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
True if there are any un-erased free regions.
Indicates whether this value definitely references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
True if there are any late-bound regions
Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
Returns 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 more
Returns true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read more
“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
True if there are any un-erased free regions.
Indicates whether this value definitely references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
True if there are any late-bound regions
Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
Returns 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 more
Returns true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read more
“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
True if there are any un-erased free regions.
Indicates whether this value definitely references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
True if there are any late-bound regions
Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
Returns 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 more
Returns true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read more
“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
True if there are any un-erased free regions.
Indicates whether this value definitely references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
True if there are any late-bound regions
Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for List<T>
impl<T> !UnwindSafe for List<T>
Blanket Implementations
Layout
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.