diff options
author | Seivan Heidari <[email protected]> | 2019-11-21 00:11:41 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-11-21 00:11:41 +0000 |
commit | 358a1bcd708c622836723e5201b6de77cc9ff327 (patch) | |
tree | aeff9c96a6059fa2b02e7c87ec88753bc7993d8d /crates/ra_hir/src/adt.rs | |
parent | 1e2d090ab8a9bda18f148b894b7948eb05b976e6 (diff) | |
parent | 612a72fc4ea4376920f2a7da7b3c334227c1716c (diff) |
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir/src/adt.rs')
-rw-r--r-- | crates/ra_hir/src/adt.rs | 54 |
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 | |||
4 | use std::sync::Arc; | ||
5 | |||
6 | use hir_def::adt::VariantData; | ||
7 | |||
8 | use crate::{ | ||
9 | db::{DefDatabase, HirDatabase}, | ||
10 | EnumVariant, Module, Name, Struct, StructField, | ||
11 | }; | ||
12 | |||
13 | impl 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)] | ||
20 | pub enum VariantDef { | ||
21 | Struct(Struct), | ||
22 | EnumVariant(EnumVariant), | ||
23 | } | ||
24 | impl_froms!(VariantDef: Struct, EnumVariant); | ||
25 | |||
26 | impl 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 | } | ||