pub enum MonoItem<'tcx> {
    Fn(Instance<'tcx>),
    Static(DefId),
    GlobalAsm(ItemId),
}

Variants§

§

Fn(Instance<'tcx>)

§

Static(DefId)

§

GlobalAsm(ItemId)

Implementations§

source§

impl<'tcx> MonoItem<'tcx>

source

pub fn is_user_defined(&self) -> bool

Returns true if the mono item is user-defined (i.e. not compiler-generated, like shims).

source

pub fn size_estimate(&self, tcx: TyCtxt<'tcx>) -> usize

source

pub fn is_generic_fn(&self, tcx: TyCtxt<'tcx>) -> bool

source

pub fn symbol_name(&self, tcx: TyCtxt<'tcx>) -> SymbolName<'tcx>

source

pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode

source

pub fn explicit_linkage(&self, tcx: TyCtxt<'tcx>) -> Option<Linkage>

source

pub fn is_instantiable(&self, tcx: TyCtxt<'tcx>) -> bool

Returns true if this instance is instantiable - whether it has no unsatisfied predicates.

In order to codegen an item, all of its predicates must hold, because otherwise the item does not make sense. Type-checking ensures that the predicates of every item that is used by a valid item do hold, so we can rely on that.

However, we codegen collector roots (reachable items) and functions in vtables when they are seen, even if they are not used, and so they might not be instantiable. For example, a programmer can define this public function:

pub fn foo<'a>(s: &'a mut ()) where &'a mut (): Clone {
    <&mut () as Clone>::clone(&s);
}

That function can’t be codegened, because the method <&mut () as Clone>::clone does not exist. Luckily for us, that function can’t ever be used, because that would require for &'a mut (): Clone to hold, so we can just not emit any code, or even a linker reference for it.

Similarly, if a vtable method has such a signature, and therefore can’t be used, we can just not emit it and have a placeholder (a null pointer, which will never be accessed) in its place.

source

pub fn local_span(&self, tcx: TyCtxt<'tcx>) -> Option<Span>

source

pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode

source

pub fn krate(&self) -> CrateNum

Returns the item’s CrateNum

source

pub fn def_id(&self) -> DefId

Returns the item’s DefId

Trait Implementations§

source§

impl<'tcx> Clone for MonoItem<'tcx>

source§

fn clone(&self) -> MonoItem<'tcx>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'tcx> Debug for MonoItem<'tcx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'tcx> Display for MonoItem<'tcx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'tcx> Hash for MonoItem<'tcx>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for MonoItem<'tcx>

source§

fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher )

source§

impl<'tcx> PartialEq for MonoItem<'tcx>

source§

fn eq(&self, other: &MonoItem<'tcx>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'tcx> Copy for MonoItem<'tcx>

source§

impl<'tcx> Eq for MonoItem<'tcx>

source§

impl<'tcx> StructuralPartialEq for MonoItem<'tcx>

Auto Trait Implementations§

§

impl<'tcx> !RefUnwindSafe for MonoItem<'tcx>

§

impl<'tcx> Send for MonoItem<'tcx>

§

impl<'tcx> Sync for MonoItem<'tcx>

§

impl<'tcx> Unpin for MonoItem<'tcx>

§

impl<'tcx> !UnwindSafe for MonoItem<'tcx>

Blanket Implementations§

source§

impl<T> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for T
where T: Copy,

source§

fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T

source§

fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T> ) -> &'a mut [T]

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

source§

impl<Tcx, T> DepNodeParams<Tcx> for T
where Tcx: DepContext, T: for<'a> HashStable<StableHashingContext<'a>> + Debug,

source§

default fn fingerprint_style() -> FingerprintStyle

source§

default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint

This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous).
source§

default fn to_debug_str(&self, _: Tcx) -> String

source§

default fn recover(_: Tcx, _: &DepNode) -> Option<T>

This method tries to recover the query key from the given DepNode, something which is needed when forcing DepNodes during red-green evaluation. The query system will only call this method if fingerprint_style() is not FingerprintStyle::Opaque. It is always valid to return None here, in which case incremental compilation will treat the query as having changed instead of forcing it.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<P> IntoQueryParam<P> for P

source§

impl<T> MaybeResult<T> for T

§

type Error = !

source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<'tcx, T> ToPredicate<'tcx, T> for T

source§

fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed ) -> T

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

Size for each variant:

  • Fn: 32 bytes
  • Static: 12 bytes
  • GlobalAsm: 8 bytes