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_rust_def_id(&self) -> Option<RDefId>
pub fn as_rust_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 underlying_rust_def_id(&self) -> Option<RDefId>
pub fn underlying_rust_def_id(&self) -> Option<RDefId>
The def_id of this item or its parent if this is a promoted constant.
Sourcepub fn as_def_id_even_synthetic(&self) -> RDefId
pub fn as_def_id_even_synthetic(&self) -> RDefId
The def_id of this item, or its parent if this is a promoted constant, or a made-up DefId
for synthetic items. The method is explicitly named to phase out DefIds for synthetic
items.
pub fn is_local(&self) -> bool
pub fn promoted_id(&self) -> Option<PromotedId>
fn make<'tcx, S: BaseState<'tcx>>(s: &S, def_id: RDefId) -> Self
pub fn make_synthetic<'tcx, S: BaseState<'tcx>>( s: &S, synthetic: SyntheticItem, def_id: RDefId, ) -> Self
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 a rustc DefId, if
any.
Note that this method relies on rustc indexes, which are session
specific. See Self documentation.
pub fn parent<'tcx>(&self, s: &impl BaseState<'tcx>) -> Option<DefId>
pub fn crate_name<'tcx>(&self, s: &impl BaseState<'tcx>) -> Symbol
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 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.
Source§impl DefId
impl DefId
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.
Trait Implementations§
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 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<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<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)
§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