[][src]Struct rustc_middle::ty::List

#[repr(C)]pub struct List<T> {
    len: usize,
    data: [T; 0],
    opaque: OpaqueListContents,

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.


len: usizedata: [T; 0]opaque: OpaqueListContents


impl<'a, 'tcx> List<GenericArg<'tcx>>[src]

pub fn as_closure(&'a self) -> ClosureSubsts<'a>[src]

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.

pub fn as_generator(&'tcx self) -> GeneratorSubsts<'tcx>[src]

Interpret these substitutions as the substitutions of a generator type. Closure 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.

pub fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx>[src]

Creates a 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>, 

Creates a 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>(
    tcx: TyCtxt<'tcx>,
    def_id: DefId,
    mk_kind: F
) -> SubstsRef<'tcx> where
    F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, 

pub(in ty::subst) 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(in ty::subst) 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 is_noop(&self) -> bool[src]

pub fn types(&'a self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> + 'a[src]

pub fn regions(&'a self) -> impl DoubleEndedIterator<Item = Region<'tcx>> + 'a[src]

pub fn consts(
    &'a self
) -> impl DoubleEndedIterator<Item = &'tcx Const<'tcx>> + 'a

pub fn non_erasable_generics(
    &'a self
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'a

pub fn type_at(&self, i: usize) -> Ty<'tcx>[src]

pub fn region_at(&self, i: usize) -> Region<'tcx>[src]

pub fn const_at(&self, i: usize) -> &'tcx Const<'tcx>[src]

pub fn type_for_def(&self, def: &GenericParamDef) -> GenericArg<'tcx>[src]

pub fn rebase_onto(
    tcx: TyCtxt<'tcx>,
    source_ancestor: DefId,
    target_substs: SubstsRef<'tcx>
) -> SubstsRef<'tcx>

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 of f 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 for f in the impl that are needed for it to match the trait.

pub fn truncate_to(
    tcx: TyCtxt<'tcx>,
    generics: &Generics
) -> SubstsRef<'tcx>

impl<T: Copy> List<T>[src]

pub(in ty) fn from_arena<'tcx>(
    arena: &'tcx Arena<'tcx>,
    slice: &[T]
) -> &'tcx List<T>

pub fn iter(&self) -> <&List<T> as IntoIterator>::IntoIter[src]

impl<T> List<T>[src]

pub fn empty<'a>() -> &'a List<T>[src]

impl<'tcx> List<ExistentialPredicate<'tcx>>[src]

pub fn principal(&self) -> Option<ExistentialTraitRef<'tcx>>[src]

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 principal_def_id(&self) -> Option<DefId>[src]

pub fn projection_bounds<'a>(
    &'a self
) -> impl Iterator<Item = ExistentialProjection<'tcx>> + 'a

pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item = DefId> + 'a[src]

Trait Implementations

impl<T> AsRef<[T]> for List<T>[src]

impl<T: Debug> Debug for List<T>[src]

impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for &'tcx List<Ty<'tcx>>[src]

impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for &'tcx List<ExistentialPredicate<'tcx>>[src]

impl<T> Deref for List<T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<'tcx> Display for &'tcx List<ExistentialPredicate<'tcx>>[src]

impl<'tcx> Display for &'tcx List<Ty<'tcx>>[src]

impl<S: Encoder, T: Encodable<S>> Encodable<S> for List<T>[src]

impl<S: Encoder, T: Encodable<S>, '_> Encodable<S> for &'_ List<T>[src]

impl<T: Eq> Eq for List<T>[src]

impl<T> Hash for List<T>[src]

impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx List<T> where
    T: HashStable<StableHashingContext<'a>>, 

impl<'a, T: Copy> IntoIterator for &'a List<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = Copied<<&'a [T] as IntoIterator>::IntoIter>

Which kind of iterator are we turning this into?

impl<'tcx> Key for &'tcx List<Predicate<'tcx>>[src]

type CacheSelector = DefaultCacheSelector

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

type Lifted = &'tcx List<Ty<'tcx>>

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

type Lifted = &'tcx List<ExistentialPredicate<'tcx>>

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

type Lifted = &'tcx List<Predicate<'tcx>>

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

type Lifted = &'tcx List<CanonicalVarInfo<'tcx>>

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

type Lifted = &'tcx List<ProjectionKind>

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

type Lifted = &'tcx List<GenericArg<'tcx>>

impl<T> Ord for List<T> where
    T: Ord

impl<T: PartialEq> PartialEq<List<T>> for List<T>[src]

impl<T> PartialOrd<List<T>> for List<T> where
    T: PartialOrd

impl<'a, T: 'a> Pointer for &'a List<T>[src]

impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for &'tcx List<Ty<'tcx>>[src]

type Output = P

type Error = Error

impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for &'tcx List<ExistentialPredicate<'tcx>>[src]

type Output = P::DynExistential

type Error = P::Error

impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for List<Ty<'tcx>>[src]

impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for List<ExistentialPredicate<'tcx>>[src]

impl<'tcx> Relate<'tcx> for &'tcx List<ExistentialPredicate<'tcx>>[src]

impl<T: Sync> Sync for List<T>[src]

impl<'a, 'tcx, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx List<T> where
    T: HashStable<StableHashingContext<'a>>, 

impl<'tcx> TypeFoldable<'tcx> for &'tcx List<PlaceElem<'tcx>>[src]

impl<'tcx> TypeFoldable<'tcx> for &'tcx List<ExistentialPredicate<'tcx>>[src]

impl<'tcx> TypeFoldable<'tcx> for &'tcx List<Ty<'tcx>>[src]

impl<'tcx> TypeFoldable<'tcx> for &'tcx List<ProjectionKind>[src]

impl<'tcx> TypeFoldable<'tcx> for &'tcx List<Predicate<'tcx>>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for List<T>

impl<T> !Send for List<T>

impl<T> !Unpin for List<T>

impl<T> !UnwindSafe for List<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<'a, T> Captures<'a> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> MaybeResult<T> for T[src]

type Error = !

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]