Skip to main content

DefId

Struct DefId 

Source
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

Source

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.

Source

pub fn real_rust_def_id(&self) -> RDefId

The rustc def_id of this item. Panics if this is not a real rustc item.

Source

pub fn as_real_or_promoted(&self) -> Option<RDefId>

The def_id of this item or its parent if this is a promoted constant.

Source

pub fn promoted_id(&self) -> Option<PromotedId>

Source

pub fn as_derived(&self) -> Option<&DerivedItemKind>

Returns the DerivedItemKind of this item, if it is derived.

Source

pub fn as_synthetic<'tcx>( &self, _s: &impl BaseState<'tcx>, ) -> Option<SyntheticItem>

Returns the SyntheticItem encoded by this frontend DefId, if any.

Source

pub fn peel_derived(&self) -> &Self

Remove one derived-item layer, if any.

Source

pub fn derived_base(&self) -> &Self

Return the (recursive) base item if this item is derived.

Source

pub fn is_local(&self) -> bool

Source

pub fn is_typeck_child<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool

Source

fn make<'tcx, S: BaseState<'tcx>>(s: &S, def_id: RDefId) -> Self

Source

pub fn make_derived(self, kind: DerivedItemKind) -> Self

Construct a derived item based on this one.

Source

pub fn make_synthetic<'tcx, S: BaseState<'tcx>>( s: &S, synthetic: SyntheticItem, ) -> Self

Source

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.

Source

pub fn make_assoc_item_impl<'tcx, S: BaseState<'tcx>>( s: &S, vitem: VirtualImplAssocItem, ) -> Self

Source

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

Source

fn crate_name_and_disambig<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> (Symbol, u32)

Source

pub fn crate_name<'tcx>(&self, s: &impl BaseState<'tcx>) -> Symbol

Source

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.

Source

pub fn path_item<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> DisambiguatedDefPathItem

The PathItem corresponding to this item.

Source

pub fn parent<'tcx>(&self, s: &impl BaseState<'tcx>) -> Option<DefId>

The syntactic parent of this item.

Source

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

Source

pub fn can_have_generics<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool

Source

pub fn has_generics<'tcx>(&self, s: &impl BaseState<'tcx>) -> bool

Whether the item has generic parameters, its parents’ included.

Source

pub fn generics_of<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> GenericParams<'tcx, Self>

Source

pub fn identity_args<'tcx>(&self, s: &impl BaseState<'tcx>) -> GenericArgs<'tcx>

Source

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.

Source

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.

Source

pub fn param_env<'tcx>(&self, s: &impl BaseState<'tcx>) -> ParamEnv<'tcx>

Source

pub fn typing_env<'tcx>(&self, s: &impl BaseState<'tcx>) -> TypingEnv<'tcx>

Source

pub fn required_predicates<'tcx, S: BaseState<'tcx>>( &self, s: &S, ) -> ItemPredicates<'tcx, Self>

Source

pub fn type_of<'tcx, S: BaseState<'tcx>>( &self, s: &S, ) -> EarlyBinder<'tcx, Ty<'tcx>>

Source§

impl DefId

Source

pub fn visibility<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option<bool>

Gets the visibility (pub or not) of the definition. Returns None for defs that don’t have a meaningful visibility.

Source

pub fn attrs<'tcx>(&self, tcx: TyCtxt<'tcx>) -> &'tcx [Attribute]

Gets the attributes of the definition.

Source§

impl DefId

Source

pub fn impl_trait_ref<'tcx>( &self, s: &impl BaseState<'tcx>, ) -> EarlyBinder<'tcx, TraitRef<'tcx>>

The trait implemented by this impl.

Source

pub fn full_def<'tcx, S>(&self, s: &S) -> Arc<FullDef<'tcx>> ⓘ
where S: BaseState<'tcx>,

Get the full definition of this item.

Source

pub fn full_def_maybe_instantiated<'tcx, S>( &self, s: &S, args: Option<GenericArgs<'tcx>>, ) -> Arc<FullDef<'tcx>> ⓘ
where S: BaseState<'tcx>,

Get the full definition of this item, instantiated if args is Some.

Trait Implementations§

Source§

impl Clone for DefId

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DefId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for DefId

Source§

type Target = DefIdContents

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Eq for DefId

Source§

impl Hash for DefId

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl ItemId for DefId

Source§

type State<'tcx> = State<'tcx, ()>

State needed to query information about this item.
Source§

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 predicate_owner(&self) -> Self

The item whose identity is used for predicate ids.
Source§

fn generics_of<'tcx>(&self, s: &Self::State<'tcx>) -> GenericParams<'tcx, Self>

The generics of this item.
Source§

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>

The predicates defined directly on this item.
Source§

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>>

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>

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>

If this item is an associated item, return its parent.
Source§

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

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>, typing_env: TypingEnv<'tcx>, trait_impl: &Self, impl_generics: GenericArgs<'tcx>, ) -> Option<(Self, GenericArgs<'tcx>, bool)>

If this item is an associated item definition, and the given impl implements it, returns the implemented associated item along with the generics of the impl that defines it, and whether that item is final, i.e. can’t be overridden by a more specialized impl.
Source§

impl PartialEq for DefId

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'s, S: BaseState<'s>> SInto<S, DefId> for DefId

Source§

fn sinto(&self, s: &S) -> DefId

Source§

impl<S> SInto<S, DefId> for DefId

Source§

fn sinto(&self, _s: &S) -> DefId

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Dedup for T
where T: Mappable + Clone + Eq + Hash,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HashConsable for T
where T: Hash + PartialEq + Eq + Clone + Mappable,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Mappable for T
where T: Any + Send + Sync,

Source§

impl<T> MergeValue for T
where T: PartialEq + Debug,

Source§

fn merge(&mut self, other: T)

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more