pub struct ItemRef<'tcx> {
pub(crate) contents: Interned<'tcx, ItemRefContents<'tcx>>,
}Expand description
Reference to an item, with generics. Basically any mention of an item (function, type, etc) uses this.
This can refer to a top-level item or to a trait associated item. Example:
trait MyTrait<TraitType, const TraitConst: usize> {
fn meth<MethType>(...) {...}
}
fn example_call<TraitType, SelfType: MyTrait<TraitType, 12>>(x: SelfType) {
x.meth::<String>(...)
}Here, in the call x.meth::<String>(...) we will build an ItemRef that looks like:
ItemRef {
def_id = MyTrait::meth,
generic_args = [String],
trait_proofs = [<proof of `String: Sized`>],
in_trait = Some(<proof of `SelfType: MyTrait<TraitType, 12>`>,
}The in_trait TraitProof will have in its trait field a representation of the SelfType: MyTrait<TraitType, 12> predicate, which looks like:
ItemRef {
def_id = MyTrait,
generic_args = [SelfType, TraitType, 12],
trait_proofs = [],
in_trait = None,
}Fields§
§contents: Interned<'tcx, ItemRefContents<'tcx>>Implementations§
Source§impl<'tcx> ItemRef<'tcx>
impl<'tcx> ItemRef<'tcx>
Sourcepub fn instantiated_full_def<S>(&self, s: &S) -> Arc<FullDef<'tcx>> ⓘwhere
S: BaseState<'tcx>,
pub fn instantiated_full_def<S>(&self, s: &S) -> Arc<FullDef<'tcx>> ⓘwhere
S: BaseState<'tcx>,
Get the full definition of the item, instantiated with the provided generics.
Sourcepub fn drop_glue_shim<S>(&self, s: &S) -> Body<'tcx>where
S: BaseState<'tcx>,
pub fn drop_glue_shim<S>(&self, s: &S) -> Body<'tcx>where
S: BaseState<'tcx>,
Get the drop glue shim for this. Panics if the DefKind isn’t appropriate.
Sourcepub fn closure_once_shim<S>(&self, s: &S) -> Option<Body<'tcx>>where
S: BaseState<'tcx>,
pub fn closure_once_shim<S>(&self, s: &S) -> Option<Body<'tcx>>where
S: BaseState<'tcx>,
For FnMut&Fn closures: the MIR for the call_once method; it simply calls
call_mut.
Source§impl<'tcx> ItemRef<'tcx>
impl<'tcx> ItemRef<'tcx>
Sourcepub fn translate<S: UnderOwnerState<'tcx>>(
s: &S,
def_id: RDefId,
generics: GenericArgsRef<'tcx>,
) -> ItemRef<'tcx>
pub fn translate<S: UnderOwnerState<'tcx>>( s: &S, def_id: RDefId, generics: GenericArgsRef<'tcx>, ) -> ItemRef<'tcx>
The main way to obtain an ItemRef: from a def_id and generics.
Sourcepub fn translate_from_hax_def_id<S: UnderOwnerState<'tcx>>(
s: &S,
hax_def_id: DefId,
generics: GenericArgsRef<'tcx>,
) -> ItemRef<'tcx>
pub fn translate_from_hax_def_id<S: UnderOwnerState<'tcx>>( s: &S, hax_def_id: DefId, generics: GenericArgsRef<'tcx>, ) -> ItemRef<'tcx>
Makes a ItemRef from a def_id and generics.
If (def_id, generics) points to a trait item that can be resolved to a specific impl,
translate rewrites def_id to the concrete associated item from that impl and re-bases
the generics.
For instance, <u32 as From<u8>>::from produces a ItemRef with a DefId looking
like core::convert::num::Impl#42::from when resolve_impl is true,
core::convert::From::from otherwise.
pub fn translate_projection<S: UnderOwnerState<'tcx>>( s: &S, def_id: RDefId, generics: GenericArgsRef<'tcx>, ) -> ItemRef<'tcx>
pub fn translate_from_hax_def_id_maybe_resolve<S: UnderOwnerState<'tcx>>( s: &S, hax_def_id: DefId, generics: GenericArgsRef<'tcx>, assoc_item_resolution: AssocItemResolution, ) -> ItemRef<'tcx>
Sourcepub fn dummy_without_generics<S: BaseState<'tcx>>(
s: &S,
def_id: DefId,
) -> ItemRef<'tcx>
pub fn dummy_without_generics<S: BaseState<'tcx>>( s: &S, def_id: DefId, ) -> ItemRef<'tcx>
Construct an ItemRef for items that can’t have generics (e.g. modules).
Sourcepub fn trait_associated_types<S: UnderOwnerState<'tcx>>(
&self,
s: &S,
) -> Vec<Ty<'tcx>>
pub fn trait_associated_types<S: UnderOwnerState<'tcx>>( &self, s: &S, ) -> Vec<Ty<'tcx>>
For an ItemRef that refers to a trait, this returns values for each of the non-gat
associated types of this trait and its parents, in a fixed order.
Sourcepub fn erase<S: UnderOwnerState<'tcx>>(&self, s: &S) -> Self
pub fn erase<S: UnderOwnerState<'tcx>>(&self, s: &S) -> Self
Erase lifetimes from the generic arguments of this item.
Sourcepub fn re_resolve<S: UnderOwnerState<'tcx>>(
&self,
s: &S,
assoc_item_resolution: AssocItemResolution,
) -> Self
pub fn re_resolve<S: UnderOwnerState<'tcx>>( &self, s: &S, assoc_item_resolution: AssocItemResolution, ) -> Self
Reconstruct this item reference with the requested associated item resolution.
pub fn contents(&self) -> &ItemRefContents<'tcx>
Sourcepub fn rustc_args<S: BaseState<'tcx>>(&self, _s: &S) -> GenericArgsRef<'tcx>
pub fn rustc_args<S: BaseState<'tcx>>(&self, _s: &S) -> GenericArgsRef<'tcx>
Recover the original rustc args that generated this ItemRef.
Sourcepub fn mutate_def_id<S: BaseState<'tcx>>(
&self,
s: &S,
f: impl FnOnce(&mut DefId),
) -> Self
pub fn mutate_def_id<S: BaseState<'tcx>>( &self, s: &S, f: impl FnOnce(&mut DefId), ) -> Self
Mutate the DefId, keeping the same generic args.
Sourcepub fn with_def_id<S: BaseState<'tcx>>(&self, s: &S, def_id: &DefId) -> Self
pub fn with_def_id<S: BaseState<'tcx>>(&self, s: &S, def_id: &DefId) -> Self
Set the DefId, keeping the same generic args.
Source§impl<'tcx> ItemRef<'tcx>
impl<'tcx> ItemRef<'tcx>
pub fn translate_synthetic<S: UnderOwnerState<'tcx>>( s: &S, synthetic: SyntheticItem, generics: GenericArgsRef<'tcx>, ) -> ItemRef<'tcx>
Sourcepub fn translate_fn_ptr<S: UnderOwnerState<'tcx>>(
s: &S,
sig: PolyFnSig<'tcx>,
) -> ItemRef<'tcx>
pub fn translate_fn_ptr<S: UnderOwnerState<'tcx>>( s: &S, sig: PolyFnSig<'tcx>, ) -> ItemRef<'tcx>
Take a fn pointer and construct a reference to the corresponding synthetic item.
Trait Implementations§
impl<'tcx> Eq for ItemRef<'tcx>
impl RefUnwindSafe for ItemRef<'_>
Source§impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, ItemRef<'tcx>> for GlobalRef
The global standing for self.
impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, ItemRef<'tcx>> for GlobalRef
The global standing for self.
Source§impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, ItemRef<'tcx>> for TraitRef<'tcx>
impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, ItemRef<'tcx>> for TraitRef<'tcx>
impl<'tcx> StructuralPartialEq for ItemRef<'tcx>
impl UnwindSafe for ItemRef<'_>
Auto Trait Implementations§
impl<'tcx> DynSend for ItemRef<'tcx>
impl<'tcx> DynSync for ItemRef<'tcx>
impl<'tcx> Freeze for ItemRef<'tcx>
impl<'tcx> Send for ItemRef<'tcx>
impl<'tcx> Sync for ItemRef<'tcx>
impl<'tcx> Unpin for ItemRef<'tcx>
impl<'tcx> UnsafeUnpin for ItemRef<'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Dedup for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> HashConsable for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more