pub enum DefKind {
Show 31 variants
Mod,
Struct,
Union,
Enum,
Variant,
Trait,
TyAlias,
ForeignTy,
TraitAlias,
AssocTy,
TyParam,
Fn,
Const,
ConstParam,
Static {
safety: Safety,
mutability: Mutability,
nested: bool,
},
Ctor(CtorOf, CtorKind),
AssocFn,
AssocConst,
Macro(MacroKind),
ExternCrate,
Use,
ForeignMod,
AnonConst,
InlineConst,
OpaqueTy,
Field,
LifetimeParam,
GlobalAsm,
Impl {
of_trait: bool,
},
Closure,
SyntheticCoroutineBody,
}
Expand description
What kind of definition something is; e.g., mod
vs struct
.
enum DefPathData
may need to be updated if a new variant is added here.
Variants§
Mod
Struct
Refers to the struct itself, DefKind::Ctor
refers to its constructor if it exists.
Union
Enum
Variant
Refers to the variant itself, DefKind::Ctor
refers to its constructor if it exists.
Trait
TyAlias
Type alias: type Foo = Bar;
ForeignTy
Type from an extern
block.
TraitAlias
Trait alias: trait IntIterator = Iterator<Item = i32>;
AssocTy
Associated type: trait MyTrait { type Assoc; }
TyParam
Type parameter: the T
in struct Vec<T> { ... }
Fn
Const
ConstParam
Constant generic parameter: struct Foo<const N: usize> { ... }
Static
Fields
mutability: Mutability
Whether it’s a static mut
or just a static
.
Ctor(CtorOf, CtorKind)
Refers to the struct or enum variant’s constructor.
The reason Ctor
exists in addition to DefKind::Struct
and
DefKind::Variant
is because structs and enum variants exist
in the type namespace, whereas struct and enum variant constructors
exist in the value namespace.
You may wonder why enum variants exist in the type namespace as opposed to the value namespace. Check out RFC 2593 for intuition on why that is.
AssocFn
Associated function: impl MyStruct { fn associated() {} }
or trait Foo { fn associated() {} }
AssocConst
Associated constant: trait MyTrait { const ASSOC: usize; }
Macro(MacroKind)
ExternCrate
Use
ForeignMod
An extern
block.
AnonConst
Anonymous constant, e.g. the 1 + 2
in [u8; 1 + 2]
InlineConst
An inline constant, e.g. const { 1 + 2 }
OpaqueTy
Opaque type, aka impl Trait
.
Field
A field in a struct, enum or union. e.g.
bar
instruct Foo { bar: u8 }
Foo::Bar::0
inenum Foo { Bar(u8) }
LifetimeParam
Lifetime parameter: the 'a
in struct Foo<'a> { ... }
GlobalAsm
A use of global_asm!
.
Impl
Closure
A closure, coroutine, or coroutine-closure.
These are all represented with the same ExprKind::Closure
in the AST and HIR,
which makes it difficult to distinguish these during def collection. Therefore,
we treat them all the same, and code which needs to distinguish them can match
or hir::ClosureKind
or type_of
.
SyntheticCoroutineBody
The definition of a synthetic coroutine body created by the lowering of a coroutine-closure, such as an async closure.
Implementations§
Source§impl DefKind
impl DefKind
Sourcepub fn descr(self, def_id: DefId) -> &'static str
pub fn descr(self, def_id: DefId) -> &'static str
Get an English description for the item’s kind.
If you have access to TyCtxt
, use TyCtxt::def_descr
or
TyCtxt::def_kind_descr
instead, because they give better
information for coroutines and associated functions.
Sourcepub fn article(&self) -> &'static str
pub fn article(&self) -> &'static str
Gets an English article for the definition.
If you have access to TyCtxt
, use TyCtxt::def_descr_article
or
TyCtxt::def_kind_descr_article
instead, because they give better
information for coroutines and associated functions.
pub fn ns(&self) -> Option<Namespace>
pub fn def_path_data(self, name: Symbol) -> DefPathData
pub fn is_fn_like(self) -> bool
Sourcepub fn has_codegen_attrs(self) -> bool
pub fn has_codegen_attrs(self) -> bool
Whether query get_codegen_attrs
should be used with this definition.
Trait Implementations§
Source§impl<__D: SpanDecoder> Decodable<__D> for DefKind
impl<__D: SpanDecoder> Decodable<__D> for DefKind
Source§impl<__E: SpanEncoder> Encodable<__E> for DefKind
impl<__E: SpanEncoder> Encodable<__E> for DefKind
Source§impl<__CTX> HashStable<__CTX> for DefKindwhere
__CTX: HashStableContext,
impl<__CTX> HashStable<__CTX> for DefKindwhere
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
impl Copy for DefKind
impl Eq for DefKind
impl StructuralPartialEq for DefKind
Auto Trait Implementations§
impl DynSend for DefKind
impl DynSync for DefKind
impl Freeze for DefKind
impl RefUnwindSafe for DefKind
impl Send for DefKind
impl Sync for DefKind
impl Unpin for DefKind
impl UnwindSafe for DefKind
Blanket Implementations§
Source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 3 bytes
Size for each variant:
Mod
: 0 bytesStruct
: 0 bytesUnion
: 0 bytesEnum
: 0 bytesVariant
: 0 bytesTrait
: 0 bytesTyAlias
: 0 bytesForeignTy
: 0 bytesTraitAlias
: 0 bytesAssocTy
: 0 bytesTyParam
: 0 bytesFn
: 0 bytesConst
: 0 bytesConstParam
: 0 bytesStatic
: 3 bytesCtor
: 3 bytesAssocFn
: 0 bytesAssocConst
: 0 bytesMacro
: 2 bytesExternCrate
: 0 bytesUse
: 0 bytesForeignMod
: 0 bytesAnonConst
: 0 bytesInlineConst
: 0 bytesOpaqueTy
: 0 bytesField
: 0 bytesLifetimeParam
: 0 bytesGlobalAsm
: 0 bytesImpl
: 2 bytesClosure
: 0 bytesSyntheticCoroutineBody
: 0 bytes