diff options
author | Aleksey Kladov <[email protected]> | 2019-11-22 18:52:06 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-22 18:52:06 +0000 |
commit | d8caf56dfc9eb3cdddff05b58b954a78cf1b9476 (patch) | |
tree | 0accd61a43762a6a34ae046ef6e23c3f7a930910 /crates/ra_hir_def | |
parent | 4d49b5d174430feede9833c5e66c39ee41b5fa3e (diff) |
Uniformalize naming
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index d04f54e15..2bd18255c 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -30,13 +30,9 @@ pub struct EnumVariantData { | |||
30 | pub variant_data: Arc<VariantData>, | 30 | pub variant_data: Arc<VariantData>, |
31 | } | 31 | } |
32 | 32 | ||
33 | /// Fields of an enum variant or struct | ||
34 | #[derive(Debug, Clone, PartialEq, Eq)] | 33 | #[derive(Debug, Clone, PartialEq, Eq)] |
35 | pub struct VariantData(VariantDataInner); | 34 | pub enum VariantData { |
36 | 35 | Record(Arena<LocalStructFieldId, StructFieldData>), | |
37 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
38 | enum VariantDataInner { | ||
39 | Struct(Arena<LocalStructFieldId, StructFieldData>), | ||
40 | Tuple(Arena<LocalStructFieldId, StructFieldData>), | 36 | Tuple(Arena<LocalStructFieldId, StructFieldData>), |
41 | Unit, | 37 | Unit, |
42 | } | 38 | } |
@@ -86,7 +82,7 @@ impl EnumData { | |||
86 | 82 | ||
87 | impl VariantData { | 83 | impl VariantData { |
88 | fn new(flavor: ast::StructKind) -> Self { | 84 | fn new(flavor: ast::StructKind) -> Self { |
89 | let inner = match flavor { | 85 | match flavor { |
90 | ast::StructKind::Tuple(fl) => { | 86 | ast::StructKind::Tuple(fl) => { |
91 | let fields = fl | 87 | let fields = fl |
92 | .fields() | 88 | .fields() |
@@ -96,9 +92,9 @@ impl VariantData { | |||
96 | type_ref: TypeRef::from_ast_opt(fd.type_ref()), | 92 | type_ref: TypeRef::from_ast_opt(fd.type_ref()), |
97 | }) | 93 | }) |
98 | .collect(); | 94 | .collect(); |
99 | VariantDataInner::Tuple(fields) | 95 | VariantData::Tuple(fields) |
100 | } | 96 | } |
101 | ast::StructKind::Named(fl) => { | 97 | ast::StructKind::Record(fl) => { |
102 | let fields = fl | 98 | let fields = fl |
103 | .fields() | 99 | .fields() |
104 | .map(|fd| StructFieldData { | 100 | .map(|fd| StructFieldData { |
@@ -106,16 +102,15 @@ impl VariantData { | |||
106 | type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), | 102 | type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), |
107 | }) | 103 | }) |
108 | .collect(); | 104 | .collect(); |
109 | VariantDataInner::Struct(fields) | 105 | VariantData::Record(fields) |
110 | } | 106 | } |
111 | ast::StructKind::Unit => VariantDataInner::Unit, | 107 | ast::StructKind::Unit => VariantData::Unit, |
112 | }; | 108 | } |
113 | VariantData(inner) | ||
114 | } | 109 | } |
115 | 110 | ||
116 | pub fn fields(&self) -> Option<&Arena<LocalStructFieldId, StructFieldData>> { | 111 | pub fn fields(&self) -> Option<&Arena<LocalStructFieldId, StructFieldData>> { |
117 | match &self.0 { | 112 | match self { |
118 | VariantDataInner::Struct(fields) | VariantDataInner::Tuple(fields) => Some(fields), | 113 | VariantData::Record(fields) | VariantData::Tuple(fields) => Some(fields), |
119 | _ => None, | 114 | _ => None, |
120 | } | 115 | } |
121 | } | 116 | } |