pub struct DefId {
pub(crate) contents: HashConsed<DefIdContents>,
}Expand description
Reflects rustc_hir::def_id::DefId, augmented to also give ids to promoted constants (which
have their own ad-hoc numbering scheme in rustc for now).
Fields§
§contents: HashConsed<DefIdContents>Implementations§
Source§impl DefId
impl DefId
Sourcepub fn as_real_def_id(&self) -> Option<RDefId>
pub fn as_real_def_id(&self) -> Option<RDefId>
The rustc def_id corresponding to this item, if there is one. Promoted constants don’t have a rustc def_id.
Sourcepub fn real_rust_def_id(&self) -> RDefId
pub fn real_rust_def_id(&self) -> RDefId
The rustc def_id of this item. Panics if this is not a real rustc item.
Sourcepub fn as_real_or_promoted(&self) -> Option<RDefId>
pub fn as_real_or_promoted(&self) -> Option<RDefId>
The def_id of this item or its parent if this is a promoted constant.
pub fn promoted_id(&self) -> Option<PromotedId>
Sourcepub fn as_derived(&self) -> Option<&DerivedItemKind>
pub fn as_derived(&self) -> Option<&DerivedItemKind>
Returns the DerivedItemKind of this item, if it is derived.
Sourcepub fn as_synthetic<'tcx>(
&self,
_s: &impl BaseState<'tcx>,
) -> Option<SyntheticItem>
pub fn as_synthetic<'tcx>( &self, _s: &impl BaseState<'tcx>, ) -> Option<SyntheticItem>
Returns the SyntheticItem encoded by this frontend DefId, if any.
Sourcepub fn peel_derived(&self) -> &Self
pub fn peel_derived(&self) -> &Self
Remove one derived-item layer, if any.
Sourcepub fn derived_base(&self) -> &Self
pub fn derived_base(&self) -> &Self
Return the (recursive) base item if this item is derived.
pub fn is_local(&self) -> bool
pub fn is_typeck_child<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool
fn make<'tcx, S: BaseState<'tcx>>(s: &S, def_id: RDefId) -> Self
Sourcepub fn make_derived(self, kind: DerivedItemKind) -> Self
pub fn make_derived(self, kind: DerivedItemKind) -> Self
Construct a derived item based on this one.
pub fn make_synthetic<'tcx, S: BaseState<'tcx>>( s: &S, synthetic: SyntheticItem, ) -> Self
Sourcepub fn make_promoted_child<'tcx, S: BaseState<'tcx>>(
&self,
s: &S,
promoted_id: PromotedId,
) -> Self
pub fn make_promoted_child<'tcx, S: BaseState<'tcx>>( &self, s: &S, promoted_id: PromotedId, ) -> Self
Construct a frontend DefId for the nth promoted constant of the current item. That DefId has
no corresponding rustc DefId.
pub fn make_assoc_item_impl<'tcx, S: BaseState<'tcx>>( s: &S, vitem: VirtualImplAssocItem, ) -> Self
Sourcepub fn make_anon_alloc<'tcx, S: BaseState<'tcx>>(
s: &S,
alloc_id: RAllocId,
) -> Self
pub fn make_anon_alloc<'tcx, S: BaseState<'tcx>>( s: &S, alloc_id: RAllocId, ) -> Self
The global standing for an anonymous allocation.
Source§impl DefId
impl DefId
fn crate_name_and_disambig<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> (Symbol, u32)
pub fn crate_name<'tcx>(&self, s: &impl BaseState<'tcx>) -> Symbol
Sourcepub fn def_span<'tcx>(&self, s: &impl BaseState<'tcx>) -> Span
pub fn def_span<'tcx>(&self, s: &impl BaseState<'tcx>) -> Span
Get the span of the definition of this item. This is the span used in diagnostics when referring to the item.
Sourcepub fn path_item<'tcx>(
&self,
s: &impl BaseState<'tcx>,
) -> DisambiguatedDefPathItem
pub fn path_item<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> DisambiguatedDefPathItem
The PathItem corresponding to this item.
Sourcepub fn parent<'tcx>(&self, s: &impl BaseState<'tcx>) -> Option<DefId>
pub fn parent<'tcx>(&self, s: &impl BaseState<'tcx>) -> Option<DefId>
The syntactic parent of this item.
Sourcepub fn typing_parent<'tcx>(&self, s: &impl BaseState<'tcx>) -> Option<DefId>
pub fn typing_parent<'tcx>(&self, s: &impl BaseState<'tcx>) -> Option<DefId>
The semantic parent of this item, i.e. parent if they share typing contexts.
Source§impl DefId
impl DefId
pub fn can_have_generics<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool
Sourcepub fn has_generics<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool
pub fn has_generics<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool
Whether the item has generic parameters, its parents’ included.
pub fn generics_of<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> GenericParams<'tcx, Self>
pub fn identity_args<'tcx>(&self, s: &impl BaseState<'tcx>) -> GenericArgs<'tcx>
Sourcepub fn identity_args_with_extra_regions<'tcx>(
&self,
s: &impl BaseState<'tcx>,
) -> (GenericArgs<'tcx>, Vec<PlaceholderRegion<'tcx>>)
pub fn identity_args_with_extra_regions<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> (GenericArgs<'tcx>, Vec<PlaceholderRegion<'tcx>>)
The identity arguments, with any erased lifetimes replaced with placeholders regions.
Sourcefn extra_ty_alias_clauses<'tcx>(
&self,
s: &impl BaseState<'tcx>,
) -> Vec<Clause<'tcx>>
fn extra_ty_alias_clauses<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> Vec<Clause<'tcx>>
Additional clauses we add to type aliases to make them well-formed.
pub fn param_env<'tcx>(&self, s: &impl BaseState<'tcx>) -> ParamEnv<'tcx>
pub fn typing_env<'tcx>(&self, s: &impl BaseState<'tcx>) -> TypingEnv<'tcx>
pub fn required_predicates<'tcx, S: BaseState<'tcx>>( &self, s: &S, ) -> ItemPredicates<'tcx, Self>
pub fn type_of<'tcx, S: BaseState<'tcx>>( &self, s: &S, ) -> EarlyBinder<'tcx, Ty<'tcx>>
Trait Implementations§
impl Eq for DefId
Source§impl ItemId for DefId
impl ItemId for DefId
Source§fn from_rust_def_id<'tcx>(s: &Self::State<'tcx>, def_id: RDefId) -> Self
fn from_rust_def_id<'tcx>(s: &Self::State<'tcx>, def_id: RDefId) -> Self
Source§fn predicate_owner(&self) -> Self
fn predicate_owner(&self) -> Self
Source§fn generics_of<'tcx>(&self, s: &Self::State<'tcx>) -> GenericParams<'tcx, Self>
fn generics_of<'tcx>(&self, s: &Self::State<'tcx>) -> GenericParams<'tcx, Self>
Source§fn param_env<'tcx>(&self, s: &Self::State<'tcx>) -> ParamEnv<'tcx>
fn param_env<'tcx>(&self, s: &Self::State<'tcx>) -> ParamEnv<'tcx>
Source§fn predicates_defined_on<'tcx>(
&self,
s: &Self::State<'tcx>,
direction: PredicateDirection,
) -> ItemPredicates<'tcx, Self>
fn predicates_defined_on<'tcx>( &self, s: &Self::State<'tcx>, direction: PredicateDirection, ) -> ItemPredicates<'tcx, Self>
Source§fn self_pred<'tcx>(&self, s: &Self::State<'tcx>) -> Option<PolyTraitRef<'tcx>>
fn self_pred<'tcx>(&self, s: &Self::State<'tcx>) -> Option<PolyTraitRef<'tcx>>
Source§fn as_identity_assoc_ty<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Ty<'tcx>>
fn as_identity_assoc_ty<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Ty<'tcx>>
Source§fn typeck_parent<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
fn typeck_parent<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
Source§fn parent_of_assoc<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
fn parent_of_assoc<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
Source§fn parent_for_clauses<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
fn parent_for_clauses<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
Source§fn takes_explicit_self_clause<'tcx>(&self, s: &Self::State<'tcx>) -> bool
fn takes_explicit_self_clause<'tcx>(&self, s: &Self::State<'tcx>) -> bool
Self: Trait clause or whether it is allowed to refer
to the ambiant one. Only relevant for associated items.Source§fn find_in_impl<'tcx>(
&self,
s: &Self::State<'tcx>,
typing_env: TypingEnv<'tcx>,
trait_impl: &Self,
impl_generics: GenericArgs<'tcx>,
) -> Option<(Self, GenericArgs<'tcx>, bool)>
fn find_in_impl<'tcx>( &self, s: &Self::State<'tcx>, typing_env: TypingEnv<'tcx>, trait_impl: &Self, impl_generics: GenericArgs<'tcx>, ) -> Option<(Self, GenericArgs<'tcx>, bool)>
impl StructuralPartialEq for DefId
Auto Trait Implementations§
impl DynSend for DefId
impl DynSync for DefId
impl Forget for DefId
impl Freeze for DefId
impl Move for DefId
impl RefUnwindSafe for DefId
impl Send for DefId
impl Sync for DefId
impl Unpin for DefId
impl UnsafeUnpin for DefId
impl UnwindSafe for DefId
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> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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