Skip to main content

Key

Type Alias Key 

Source
pub type Key<'tcx> = InstanceKind<'tcx>;

Aliased Type§

pub enum Key<'tcx> {
    Item(DefId),
    Intrinsic(DefId),
    Virtual(DefId, usize),
    Shim(ShimKind<'tcx>),
}

Variants§

§

Item(DefId)

A user-defined callable item.

This includes:

  • fn items
  • closures
  • coroutines
§

Intrinsic(DefId)

An intrinsic fn item (with#[rustc_intrinsic]).

Alongside Virtual, this is the only InstanceKind that does not have its own callable MIR. Instead, codegen and const eval “magically” evaluate calls to intrinsics purely in the caller.

§

Virtual(DefId, usize)

Dynamic dispatch to <dyn Trait as Trait>::fn.

This InstanceKind may have a callable MIR as the default implementation. Calls to Virtual instances must be codegen’d as virtual calls through the vtable. This means we might not know exactly what is being called.

If this is reified to a fn pointer, a ReifyShim is used (see ReifyShim above for more details on that).

§

Shim(ShimKind<'tcx>)

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: 24 bytes

Size for each variant:

  • Item: 12 bytes
  • Intrinsic: 12 bytes
  • Virtual: 24 bytes
  • Shim: 24 bytes