aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/adt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/adt.rs')
-rw-r--r--crates/ra_hir/src/adt.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
deleted file mode 100644
index 945f236c2..000000000
--- a/crates/ra_hir/src/adt.rs
+++ /dev/null
@@ -1,54 +0,0 @@
1//! This module contains the implementation details of the HIR for ADTs, i.e.
2//! structs and enums (and unions).
3
4use std::sync::Arc;
5
6use hir_def::adt::VariantData;
7
8use crate::{
9 db::{DefDatabase, HirDatabase},
10 EnumVariant, Module, Name, Struct, StructField,
11};
12
13impl Struct {
14 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
15 db.struct_data(self.id.into()).variant_data.clone()
16 }
17}
18
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
20pub enum VariantDef {
21 Struct(Struct),
22 EnumVariant(EnumVariant),
23}
24impl_froms!(VariantDef: Struct, EnumVariant);
25
26impl VariantDef {
27 pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> {
28 match self {
29 VariantDef::Struct(it) => it.fields(db),
30 VariantDef::EnumVariant(it) => it.fields(db),
31 }
32 }
33
34 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
35 match self {
36 VariantDef::Struct(it) => it.field(db, name),
37 VariantDef::EnumVariant(it) => it.field(db, name),
38 }
39 }
40
41 pub fn module(self, db: &impl HirDatabase) -> Module {
42 match self {
43 VariantDef::Struct(it) => it.module(db),
44 VariantDef::EnumVariant(it) => it.module(db),
45 }
46 }
47
48 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
49 match self {
50 VariantDef::Struct(it) => it.variant_data(db),
51 VariantDef::EnumVariant(it) => it.variant_data(db),
52 }
53 }
54}