aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-30 15:49:39 +0100
committerGitHub <[email protected]>2020-07-30 15:49:39 +0100
commita257fd06b36d2e7310e5e38823f6636343a37331 (patch)
treee360ad1f518319883677364f49d75d5c508aafcd /crates/ra_hir_def/src
parent282702c2877e3f9002308b1b63fc472b5e799c56 (diff)
parent0a9e3ccc262fbcbd4cdaab30384f8cb71584544b (diff)
Merge #5597
5597: Rename FieldDef -> Field r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/adt.rs6
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs29
-rw-r--r--crates/ra_hir_def/src/keys.rs4
3 files changed, 20 insertions, 19 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs
index 4994a2125..2be23c45d 100644
--- a/crates/ra_hir_def/src/adt.rs
+++ b/crates/ra_hir_def/src/adt.rs
@@ -179,7 +179,7 @@ impl VariantData {
179 179
180impl HasChildSource for VariantId { 180impl HasChildSource for VariantId {
181 type ChildId = LocalFieldId; 181 type ChildId = LocalFieldId;
182 type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; 182 type Value = Either<ast::TupleField, ast::RecordField>;
183 183
184 fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { 184 fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> {
185 let (src, module_id) = match self { 185 let (src, module_id) = match self {
@@ -194,7 +194,7 @@ impl HasChildSource for VariantId {
194 } 194 }
195 VariantId::UnionId(it) => ( 195 VariantId::UnionId(it) => (
196 it.lookup(db).source(db).map(|it| { 196 it.lookup(db).source(db).map(|it| {
197 it.record_field_def_list() 197 it.record_field_list()
198 .map(ast::StructKind::Record) 198 .map(ast::StructKind::Record)
199 .unwrap_or(ast::StructKind::Unit) 199 .unwrap_or(ast::StructKind::Unit)
200 }), 200 }),
@@ -218,7 +218,7 @@ pub enum StructKind {
218fn lower_struct( 218fn lower_struct(
219 db: &dyn DefDatabase, 219 db: &dyn DefDatabase,
220 expander: &mut CfgExpander, 220 expander: &mut CfgExpander,
221 trace: &mut Trace<FieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, 221 trace: &mut Trace<FieldData, Either<ast::TupleField, ast::RecordField>>,
222 ast: &InFile<ast::StructKind>, 222 ast: &InFile<ast::StructKind>,
223) -> StructKind { 223) -> StructKind {
224 let ctx = LowerCtx::new(db, ast.file_id); 224 let ctx = LowerCtx::new(db, ast.file_id);
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index 19d165b5b..df909ee9e 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -1,10 +1,7 @@
1//! AST -> `ItemTree` lowering code. 1//! AST -> `ItemTree` lowering code.
2 2
3use super::*; 3use std::{collections::hash_map::Entry, mem, sync::Arc};
4use crate::{ 4
5 attr::Attrs,
6 generics::{GenericParams, TypeParamData, TypeParamProvenance},
7};
8use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; 5use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId};
9use ra_arena::map::ArenaMap; 6use ra_arena::map::ArenaMap;
10use ra_syntax::{ 7use ra_syntax::{
@@ -12,7 +9,13 @@ use ra_syntax::{
12 SyntaxNode, 9 SyntaxNode,
13}; 10};
14use smallvec::SmallVec; 11use smallvec::SmallVec;
15use std::{collections::hash_map::Entry, mem, sync::Arc}; 12
13use crate::{
14 attr::Attrs,
15 generics::{GenericParams, TypeParamData, TypeParamProvenance},
16};
17
18use super::*;
16 19
17fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> { 20fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> {
18 FileItemTreeId { index, _p: PhantomData } 21 FileItemTreeId { index, _p: PhantomData }
@@ -191,7 +194,7 @@ impl Ctx {
191 } 194 }
192 } 195 }
193 196
194 fn lower_record_fields(&mut self, fields: &ast::RecordFieldDefList) -> IdRange<Field> { 197 fn lower_record_fields(&mut self, fields: &ast::RecordFieldList) -> IdRange<Field> {
195 let start = self.next_field_idx(); 198 let start = self.next_field_idx();
196 for field in fields.fields() { 199 for field in fields.fields() {
197 if let Some(data) = self.lower_record_field(&field) { 200 if let Some(data) = self.lower_record_field(&field) {
@@ -203,7 +206,7 @@ impl Ctx {
203 IdRange::new(start..end) 206 IdRange::new(start..end)
204 } 207 }
205 208
206 fn lower_record_field(&mut self, field: &ast::RecordFieldDef) -> Option<Field> { 209 fn lower_record_field(&mut self, field: &ast::RecordField) -> Option<Field> {
207 let name = field.name()?.as_name(); 210 let name = field.name()?.as_name();
208 let visibility = self.lower_visibility(field); 211 let visibility = self.lower_visibility(field);
209 let type_ref = self.lower_type_ref_opt(field.ascribed_type()); 212 let type_ref = self.lower_type_ref_opt(field.ascribed_type());
@@ -211,7 +214,7 @@ impl Ctx {
211 Some(res) 214 Some(res)
212 } 215 }
213 216
214 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldDefList) -> IdRange<Field> { 217 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldList) -> IdRange<Field> {
215 let start = self.next_field_idx(); 218 let start = self.next_field_idx();
216 for (i, field) in fields.fields().enumerate() { 219 for (i, field) in fields.fields().enumerate() {
217 let data = self.lower_tuple_field(i, &field); 220 let data = self.lower_tuple_field(i, &field);
@@ -222,7 +225,7 @@ impl Ctx {
222 IdRange::new(start..end) 225 IdRange::new(start..end)
223 } 226 }
224 227
225 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleFieldDef) -> Field { 228 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleField) -> Field {
226 let name = Name::new_tuple_field(idx); 229 let name = Name::new_tuple_field(idx);
227 let visibility = self.lower_visibility(field); 230 let visibility = self.lower_visibility(field);
228 let type_ref = self.lower_type_ref_opt(field.type_ref()); 231 let type_ref = self.lower_type_ref_opt(field.type_ref());
@@ -234,10 +237,8 @@ impl Ctx {
234 let visibility = self.lower_visibility(union); 237 let visibility = self.lower_visibility(union);
235 let name = union.name()?.as_name(); 238 let name = union.name()?.as_name();
236 let generic_params = self.lower_generic_params(GenericsOwner::Union, union); 239 let generic_params = self.lower_generic_params(GenericsOwner::Union, union);
237 let fields = match union.record_field_def_list() { 240 let fields = match union.record_field_list() {
238 Some(record_field_def_list) => { 241 Some(record_field_list) => self.lower_fields(&StructKind::Record(record_field_list)),
239 self.lower_fields(&StructKind::Record(record_field_def_list))
240 }
241 None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())), 242 None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())),
242 }; 243 };
243 let ast_id = self.source_ast_id_map.ast_id(union); 244 let ast_id = self.source_ast_id_map.ast_id(union);
diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs
index f627eab1f..9ca276235 100644
--- a/crates/ra_hir_def/src/keys.rs
+++ b/crates/ra_hir_def/src/keys.rs
@@ -25,8 +25,8 @@ pub const UNION: Key<ast::UnionDef, UnionId> = Key::new();
25pub const ENUM: Key<ast::EnumDef, EnumId> = Key::new(); 25pub const ENUM: Key<ast::EnumDef, EnumId> = Key::new();
26 26
27pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new(); 27pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new();
28pub const TUPLE_FIELD: Key<ast::TupleFieldDef, FieldId> = Key::new(); 28pub const TUPLE_FIELD: Key<ast::TupleField, FieldId> = Key::new();
29pub const RECORD_FIELD: Key<ast::RecordFieldDef, FieldId> = Key::new(); 29pub const RECORD_FIELD: Key<ast::RecordField, FieldId> = Key::new();
30pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new(); 30pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new();
31 31
32pub const MACRO: Key<ast::MacroCall, MacroDefId> = Key::new(); 32pub const MACRO: Key<ast::MacroCall, MacroDefId> = Key::new();