diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-25 13:25:28 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-25 13:25:28 +0100 |
commit | 05981823bac91ba338110902fd435c6e3166f1d6 (patch) | |
tree | 24b14acc3cfb37489c413c0dfba16dbc8b630869 /crates/ra_hir_def/src/adt.rs | |
parent | 7bc71732300a57fad928393220ecbe5f751cc20f (diff) | |
parent | 970dbf871795650ecf49b7198d53bdcad9c612af (diff) |
Merge #4135
4135: Rename StructField -> Field r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/adt.rs')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 7c0d93691..753becc3d 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -14,7 +14,7 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner, VisibilityOwner}; | |||
14 | use crate::{ | 14 | use crate::{ |
15 | body::CfgExpander, db::DefDatabase, src::HasChildSource, src::HasSource, trace::Trace, | 15 | body::CfgExpander, db::DefDatabase, src::HasChildSource, src::HasSource, trace::Trace, |
16 | type_ref::TypeRef, visibility::RawVisibility, EnumId, HasModule, LocalEnumVariantId, | 16 | type_ref::TypeRef, visibility::RawVisibility, EnumId, HasModule, LocalEnumVariantId, |
17 | LocalStructFieldId, Lookup, ModuleId, StructId, UnionId, VariantId, | 17 | LocalFieldId, Lookup, ModuleId, StructId, UnionId, VariantId, |
18 | }; | 18 | }; |
19 | 19 | ||
20 | /// Note that we use `StructData` for unions as well! | 20 | /// Note that we use `StructData` for unions as well! |
@@ -38,14 +38,14 @@ pub struct EnumVariantData { | |||
38 | 38 | ||
39 | #[derive(Debug, Clone, PartialEq, Eq)] | 39 | #[derive(Debug, Clone, PartialEq, Eq)] |
40 | pub enum VariantData { | 40 | pub enum VariantData { |
41 | Record(Arena<StructFieldData>), | 41 | Record(Arena<FieldData>), |
42 | Tuple(Arena<StructFieldData>), | 42 | Tuple(Arena<FieldData>), |
43 | Unit, | 43 | Unit, |
44 | } | 44 | } |
45 | 45 | ||
46 | /// A single field of an enum variant or struct | 46 | /// A single field of an enum variant or struct |
47 | #[derive(Debug, Clone, PartialEq, Eq)] | 47 | #[derive(Debug, Clone, PartialEq, Eq)] |
48 | pub struct StructFieldData { | 48 | pub struct FieldData { |
49 | pub name: Name, | 49 | pub name: Name, |
50 | pub type_ref: TypeRef, | 50 | pub type_ref: TypeRef, |
51 | pub visibility: RawVisibility, | 51 | pub visibility: RawVisibility, |
@@ -133,15 +133,15 @@ impl VariantData { | |||
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | pub fn fields(&self) -> &Arena<StructFieldData> { | 136 | pub fn fields(&self) -> &Arena<FieldData> { |
137 | const EMPTY: &Arena<StructFieldData> = &Arena::new(); | 137 | const EMPTY: &Arena<FieldData> = &Arena::new(); |
138 | match &self { | 138 | match &self { |
139 | VariantData::Record(fields) | VariantData::Tuple(fields) => fields, | 139 | VariantData::Record(fields) | VariantData::Tuple(fields) => fields, |
140 | _ => EMPTY, | 140 | _ => EMPTY, |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | pub fn field(&self, name: &Name) -> Option<LocalStructFieldId> { | 144 | pub fn field(&self, name: &Name) -> Option<LocalFieldId> { |
145 | self.fields().iter().find_map(|(id, data)| if &data.name == name { Some(id) } else { None }) | 145 | self.fields().iter().find_map(|(id, data)| if &data.name == name { Some(id) } else { None }) |
146 | } | 146 | } |
147 | 147 | ||
@@ -155,7 +155,7 @@ impl VariantData { | |||
155 | } | 155 | } |
156 | 156 | ||
157 | impl HasChildSource for VariantId { | 157 | impl HasChildSource for VariantId { |
158 | type ChildId = LocalStructFieldId; | 158 | type ChildId = LocalFieldId; |
159 | type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; | 159 | type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; |
160 | 160 | ||
161 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { | 161 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { |
@@ -195,7 +195,7 @@ pub enum StructKind { | |||
195 | fn lower_struct( | 195 | fn lower_struct( |
196 | db: &dyn DefDatabase, | 196 | db: &dyn DefDatabase, |
197 | expander: &mut CfgExpander, | 197 | expander: &mut CfgExpander, |
198 | trace: &mut Trace<StructFieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, | 198 | trace: &mut Trace<FieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, |
199 | ast: &InFile<ast::StructKind>, | 199 | ast: &InFile<ast::StructKind>, |
200 | ) -> StructKind { | 200 | ) -> StructKind { |
201 | match &ast.value { | 201 | match &ast.value { |
@@ -208,7 +208,7 @@ fn lower_struct( | |||
208 | 208 | ||
209 | trace.alloc( | 209 | trace.alloc( |
210 | || Either::Left(fd.clone()), | 210 | || Either::Left(fd.clone()), |
211 | || StructFieldData { | 211 | || FieldData { |
212 | name: Name::new_tuple_field(i), | 212 | name: Name::new_tuple_field(i), |
213 | type_ref: TypeRef::from_ast_opt(fd.type_ref()), | 213 | type_ref: TypeRef::from_ast_opt(fd.type_ref()), |
214 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 214 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |
@@ -226,7 +226,7 @@ fn lower_struct( | |||
226 | 226 | ||
227 | trace.alloc( | 227 | trace.alloc( |
228 | || Either::Right(fd.clone()), | 228 | || Either::Right(fd.clone()), |
229 | || StructFieldData { | 229 | || FieldData { |
230 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), | 230 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), |
231 | type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), | 231 | type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), |
232 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 232 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |