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_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 hax DefId, if any.
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
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 hax 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
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.
pub fn parent<'tcx>(&self, s: &impl BaseState<'tcx>) -> Option<DefId>
Source§impl DefId
impl DefId
pub fn can_have_generics<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool
pub fn generics_of<'tcx>(&self, s: &impl BaseState<'tcx>) -> &'tcx Generics
pub fn identity_args<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> GenericArgsRef<'tcx>
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§
Source§impl ItemId for DefId
impl ItemId for DefId
Source§type State<'tcx> = State<Base<'tcx>, (), ()>
type State<'tcx> = State<Base<'tcx>, (), ()>
State needed to query information about this item.
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
An identifier that refers to a real Rust item.
Source§fn generics_of<'tcx>(&self, s: &Self::State<'tcx>) -> &'tcx Generics
fn generics_of<'tcx>(&self, s: &Self::State<'tcx>) -> &'tcx Generics
The generics of this item.
Source§fn param_env<'tcx>(&self, s: &Self::State<'tcx>) -> ParamEnv<'tcx>
fn param_env<'tcx>(&self, s: &Self::State<'tcx>) -> ParamEnv<'tcx>
The clauses that can be assumed when inside this item.
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>
The predicates defined directly on this item.
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>>
If this item is a trait, return its Self predicate.
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>>
The type of this item as an associated type projection, if it is a trait associated type.
Source§fn typeck_parent<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
fn typeck_parent<'tcx>(&self, s: &Self::State<'tcx>) -> Option<Self>
If this item is typechecked together with its parent (e.g. inline consts and closures),
return that parent.
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>
If this item is an associated item, return its parent.
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>
If this item inherits the clauses of its parent, return the parent.
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
Whether this item takes an explicit
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>,
trait_impl: &Self,
) -> Option<Self>
fn find_in_impl<'tcx>( &self, s: &Self::State<'tcx>, trait_impl: &Self, ) -> Option<Self>
If this item is an associated item definition, and the given impl implements it, returns
the implemented associated item.
impl Eq for DefId
impl StructuralPartialEq for DefId
Auto Trait Implementations§
impl Freeze 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key and return true if they are equal.§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
§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>
Converts
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>
Converts
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§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more