From 4420eb724a762eaa780d381d0c398a09da230bb4 Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Tue, 10 Dec 2024 16:02:01 +0100 Subject: [PATCH] intro(exporter): `DefKind` --- frontend/exporter/src/types/hir.rs | 50 +++++++++++++++++++++++++++-- frontend/exporter/src/types/span.rs | 2 +- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/frontend/exporter/src/types/hir.rs b/frontend/exporter/src/types/hir.rs index 1c8a23399..27e1b9705 100644 --- a/frontend/exporter/src/types/hir.rs +++ b/frontend/exporter/src/types/hir.rs @@ -62,7 +62,7 @@ impl SInto for hir::Mutability { /// Reflects [`hir::def::CtorKind`] #[derive_group(Serializers)] -#[derive(AdtInto, Clone, Debug, JsonSchema)] +#[derive(AdtInto, JsonSchema, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[args(, from: hir::def::CtorKind, state: S as _s)] pub enum CtorKind { Fn, @@ -71,7 +71,7 @@ pub enum CtorKind { /// Reflects [`hir::def::CtorOf`] #[derive_group(Serializers)] -#[derive(AdtInto, Clone, Debug, JsonSchema)] +#[derive(AdtInto, JsonSchema, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[args(, from: hir::def::CtorOf, state: S as _s)] pub enum CtorOf { Struct, @@ -1177,7 +1177,51 @@ pub enum AttrKind { DocComment(CommentKind, Symbol), } -sinto_todo!(rustc_hir::def, DefKind); +/// Reflects [`rustc_hir::def::DefKind`] +#[derive(AdtInto)] +#[args(, from: rustc_hir::def::DefKind, state: S as tcx)] +#[derive_group(Serializers)] +#[derive(Debug, JsonSchema, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub enum DefKind { + 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, +} + sinto_todo!(rustc_hir, GenericArgs<'a> as HirGenericArgs); sinto_todo!(rustc_hir, InlineAsm<'a>); sinto_todo!(rustc_hir, MissingLifetimeKind); diff --git a/frontend/exporter/src/types/span.rs b/frontend/exporter/src/types/span.rs index a179ca54e..a4b256135 100644 --- a/frontend/exporter/src/types/span.rs +++ b/frontend/exporter/src/types/span.rs @@ -38,7 +38,7 @@ pub enum AstPass { /// Reflects [`rustc_span::hygiene::MacroKind`] #[derive_group(Serializers)] -#[derive(AdtInto, Clone, Debug, JsonSchema)] +#[derive(AdtInto, JsonSchema, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[args(, from: rustc_span::hygiene::MacroKind, state: S as _s)] pub enum MacroKind { Bang,