@@ -1304,6 +1304,49 @@ crate enum TypeKind {
13041304 Primitive ,
13051305}
13061306
1307+ impl < ' a > From < & ' a hir:: def:: DefKind > for TypeKind {
1308+ fn from ( other : & hir:: def:: DefKind ) -> Self {
1309+ Self :: from ( * other)
1310+ }
1311+ }
1312+
1313+ impl From < hir:: def:: DefKind > for TypeKind {
1314+ fn from ( other : hir:: def:: DefKind ) -> Self {
1315+ match other {
1316+ hir:: def:: DefKind :: Enum => Self :: Enum ,
1317+ hir:: def:: DefKind :: Fn => Self :: Function ,
1318+ hir:: def:: DefKind :: Mod => Self :: Module ,
1319+ hir:: def:: DefKind :: Const => Self :: Const ,
1320+ hir:: def:: DefKind :: Static => Self :: Static ,
1321+ hir:: def:: DefKind :: Struct => Self :: Struct ,
1322+ hir:: def:: DefKind :: Union => Self :: Union ,
1323+ hir:: def:: DefKind :: Trait => Self :: Trait ,
1324+ hir:: def:: DefKind :: TyAlias => Self :: Typedef ,
1325+ hir:: def:: DefKind :: ForeignTy => Self :: Foreign ,
1326+ hir:: def:: DefKind :: TraitAlias => Self :: TraitAlias ,
1327+ hir:: def:: DefKind :: Macro ( _) => Self :: Macro ,
1328+ hir:: def:: DefKind :: Variant
1329+ | hir:: def:: DefKind :: AssocTy
1330+ | hir:: def:: DefKind :: TyParam
1331+ | hir:: def:: DefKind :: ConstParam
1332+ | hir:: def:: DefKind :: Ctor ( ..)
1333+ | hir:: def:: DefKind :: AssocFn
1334+ | hir:: def:: DefKind :: AssocConst
1335+ | hir:: def:: DefKind :: ExternCrate
1336+ | hir:: def:: DefKind :: Use
1337+ | hir:: def:: DefKind :: ForeignMod
1338+ | hir:: def:: DefKind :: AnonConst
1339+ | hir:: def:: DefKind :: OpaqueTy
1340+ | hir:: def:: DefKind :: Field
1341+ | hir:: def:: DefKind :: LifetimeParam
1342+ | hir:: def:: DefKind :: GlobalAsm
1343+ | hir:: def:: DefKind :: Impl
1344+ | hir:: def:: DefKind :: Closure
1345+ | hir:: def:: DefKind :: Generator => Self :: Foreign ,
1346+ }
1347+ }
1348+ }
1349+
13071350crate trait GetDefId {
13081351 /// Use this method to get the [`DefId`] of a [`clean`] AST node.
13091352 /// This will return [`None`] when called on a primitive [`clean::Type`].
0 commit comments