Enum rustc::traits::Vtable [] [src]

pub enum Vtable<'tcx, N> {
    VtableImpl(VtableImplData<'tcx, N>),
    VtableDefaultImpl(VtableDefaultImplData<N>),
    VtableParam(Vec<N>),
    VtableObject(VtableObjectData<'tcx, N>),
    VtableBuiltin(VtableBuiltinData<N>),
    VtableClosure(VtableClosureData<'tcx, N>),
    VtableFnPointer(VtableFnPointerData<'tcx, N>),
}
🔬 This is a nightly-only experimental API. (rustc_private)

Given the successful resolution of an obligation, the Vtable indicates where the vtable comes from. Note that while we call this a "vtable", it does not necessarily indicate dynamic dispatch at runtime. Vtable instances just tell the compiler where to find methods, but in generic code those methods are typically statically dispatched -- only when an object is constructed is a Vtable instance reified into an actual vtable.

For example, the vtable may be tied to a specific impl (case A), or it may be relative to some bound that is in scope (case B).

impl<T:Clone> Clone<T> for Option<T> { ... } // Impl_1
impl<T:Clone> Clone<T> for Box<T> { ... }    // Impl_2
impl Clone for int { ... }             // Impl_3

fn foo<T:Clone>(concrete: Option<Box<int>>,
                param: T,
                mixed: Option<T>) {

   // Case A: Vtable points at a specific impl. Only possible when
   // type is concretely known. If the impl itself has bounded
   // type parameters, Vtable will carry resolutions for those as well:
   concrete.clone(); // Vtable(Impl_1, [Vtable(Impl_2, [Vtable(Impl_3)])])

   // Case B: Vtable must be provided by caller. This applies when
   // type is a type parameter.
   param.clone();    // VtableParam

   // Case C: A mix of cases A and B.
   mixed.clone();    // Vtable(Impl_1, [VtableParam])
}

The type parameter N

See explanation on VtableImplData.

Variants

🔬 This is a nightly-only experimental API. (rustc_private)

Vtable identifying a particular impl.

🔬 This is a nightly-only experimental API. (rustc_private)

Vtable for default trait implementations This carries the information and nested obligations with regards to a default implementation for a trait Trait. The nested obligations ensure the trait implementation holds for all the constituent types.

🔬 This is a nightly-only experimental API. (rustc_private)

Successful resolution to an obligation provided by the caller for some type parameter. The Vec<N> represents the obligations incurred from normalizing the where-clause (if any).

🔬 This is a nightly-only experimental API. (rustc_private)

Virtual calls through an object

🔬 This is a nightly-only experimental API. (rustc_private)

Successful resolution for a builtin trait.

🔬 This is a nightly-only experimental API. (rustc_private)

Vtable automatically generated for a closure. The def ID is the ID of the closure expression. This is a VtableImpl in spirit, but the impl is generated by the compiler and does not appear in the source.

🔬 This is a nightly-only experimental API. (rustc_private)

Same as above, but for a fn pointer type with the given signature.

Methods

impl<'tcx, N> Vtable<'tcx, N>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

Trait Implementations

impl<'tcx, N: Debug> Debug for Vtable<'tcx, N>
[src]

Formats the value using the given formatter.

impl<'a, 'tcx> Lift<'tcx> for Vtable<'a, ()>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vtable<'tcx, N>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

🔬 This is a nightly-only experimental API. (rustc_private)

Indicates whether this value references only 'global' types/lifetimes that are the same regardless of what fn we are in. This is used for caching. Errs on the side of returning false. Read more

impl<'tcx, N: Clone> Clone for Vtable<'tcx, N>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more