Enum rustc_middle::mir::mono::MonoItem
source · Variants
Fn(Instance<'tcx>)
Static(DefId)
GlobalAsm(ItemId)
Implementations
sourceimpl<'tcx> MonoItem<'tcx>
impl<'tcx> MonoItem<'tcx>
sourcepub fn is_user_defined(&self) -> bool
pub fn is_user_defined(&self) -> bool
Returns true
if the mono item is user-defined (i.e. not compiler-generated, like shims).
pub fn size_estimate(&self, tcx: TyCtxt<'tcx>) -> usize
pub fn is_generic_fn(&self) -> bool
pub fn symbol_name(&self, tcx: TyCtxt<'tcx>) -> SymbolName<'tcx>
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode
pub fn explicit_linkage(&self, tcx: TyCtxt<'tcx>) -> Option<Linkage>
sourcepub fn is_instantiable(&self, tcx: TyCtxt<'tcx>) -> bool
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.
pub fn local_span(&self, tcx: TyCtxt<'tcx>) -> Option<Span>
pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode
Trait Implementations
sourceimpl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for MonoItem<'tcx>
impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for MonoItem<'tcx>
fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
sourceimpl<'tcx> PartialEq<MonoItem<'tcx>> for MonoItem<'tcx>
impl<'tcx> PartialEq<MonoItem<'tcx>> for MonoItem<'tcx>
impl<'tcx> Copy for MonoItem<'tcx>
impl<'tcx> Eq for MonoItem<'tcx>
impl<'tcx> StructuralEq for MonoItem<'tcx>
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
sourceimpl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter(
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = T>
) -> &'a mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
default fn fingerprint_style() -> FingerprintStyle
sourcedefault fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_debug_str(&self, Ctxt) -> String
sourcedefault fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
default fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
DepNode
,
something which is needed when forcing DepNode
s 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. Read moresourceimpl<T, R> InternIteratorElement<T, R> for T
impl<T, R> InternIteratorElement<T, R> for T
type Output = R
fn intern_with<I, F>(iter: I, f: F) -> <T as InternIteratorElement<T, R>>::Outputwhere
I: Iterator<Item = T>,
F: FnOnce(&[T]) -> R,
sourceimpl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
sourceimpl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
impl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
default fn from_cycle_error(tcx: CTX) -> T
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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 bytesStatic
: 12 bytesGlobalAsm
: 8 bytes