aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/adt.rs22
-rw-r--r--crates/ra_hir_def/src/attr.rs2
-rw-r--r--crates/ra_hir_def/src/child_by_source.rs6
-rw-r--r--crates/ra_hir_def/src/docs.rs2
-rw-r--r--crates/ra_hir_def/src/keys.rs6
-rw-r--r--crates/ra_hir_def/src/lib.rs10
6 files changed, 24 insertions, 24 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};
14use crate::{ 14use 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)]
40pub enum VariantData { 40pub 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)]
48pub struct StructFieldData { 48pub 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
157impl HasChildSource for VariantId { 157impl 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 {
195fn lower_struct( 195fn 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())),
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs
index 2f2e3e5ba..714a66b02 100644
--- a/crates/ra_hir_def/src/attr.rs
+++ b/crates/ra_hir_def/src/attr.rs
@@ -43,7 +43,7 @@ impl Attrs {
43 }; 43 };
44 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner)) 44 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner))
45 } 45 }
46 AttrDefId::StructFieldId(it) => { 46 AttrDefId::FieldId(it) => {
47 let src = it.parent.child_source(db); 47 let src = it.parent.child_source(db);
48 match &src.value[it.local_id] { 48 match &src.value[it.local_id] {
49 Either::Left(_tuple) => Attrs::default(), 49 Either::Left(_tuple) => Attrs::default(),
diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/ra_hir_def/src/child_by_source.rs
index 7009f21d1..a885ec96d 100644
--- a/crates/ra_hir_def/src/child_by_source.rs
+++ b/crates/ra_hir_def/src/child_by_source.rs
@@ -12,8 +12,8 @@ use crate::{
12 item_scope::ItemScope, 12 item_scope::ItemScope,
13 keys, 13 keys,
14 src::{HasChildSource, HasSource}, 14 src::{HasChildSource, HasSource},
15 AdtId, AssocItemId, DefWithBodyId, EnumId, EnumVariantId, ImplId, Lookup, ModuleDefId, 15 AdtId, AssocItemId, DefWithBodyId, EnumId, EnumVariantId, FieldId, ImplId, Lookup, ModuleDefId,
16 ModuleId, StructFieldId, TraitId, VariantId, 16 ModuleId, TraitId, VariantId,
17}; 17};
18 18
19pub trait ChildBySource { 19pub trait ChildBySource {
@@ -140,7 +140,7 @@ impl ChildBySource for VariantId {
140 let arena_map = self.child_source(db); 140 let arena_map = self.child_source(db);
141 let arena_map = arena_map.as_ref(); 141 let arena_map = arena_map.as_ref();
142 for (local_id, source) in arena_map.value.iter() { 142 for (local_id, source) in arena_map.value.iter() {
143 let id = StructFieldId { parent: *self, local_id }; 143 let id = FieldId { parent: *self, local_id };
144 match source { 144 match source {
145 Either::Left(source) => { 145 Either::Left(source) => {
146 res[keys::TUPLE_FIELD].insert(arena_map.with_value(source.clone()), id) 146 res[keys::TUPLE_FIELD].insert(arena_map.with_value(source.clone()), id)
diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs
index 0539a77d4..b221ae1ce 100644
--- a/crates/ra_hir_def/src/docs.rs
+++ b/crates/ra_hir_def/src/docs.rs
@@ -43,7 +43,7 @@ impl Documentation {
43 let src = def_map[module.local_id].declaration_source(db)?; 43 let src = def_map[module.local_id].declaration_source(db)?;
44 docs_from_ast(&src.value) 44 docs_from_ast(&src.value)
45 } 45 }
46 AttrDefId::StructFieldId(it) => { 46 AttrDefId::FieldId(it) => {
47 let src = it.parent.child_source(db); 47 let src = it.parent.child_source(db);
48 match &src.value[it.local_id] { 48 match &src.value[it.local_id] {
49 Either::Left(_tuple) => None, 49 Either::Left(_tuple) => None,
diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs
index 8cd70eb9a..a7349a21d 100644
--- a/crates/ra_hir_def/src/keys.rs
+++ b/crates/ra_hir_def/src/keys.rs
@@ -8,7 +8,7 @@ use rustc_hash::FxHashMap;
8 8
9use crate::{ 9use crate::{
10 dyn_map::{DynMap, Policy}, 10 dyn_map::{DynMap, Policy},
11 ConstId, EnumId, EnumVariantId, FunctionId, ImplId, StaticId, StructFieldId, StructId, TraitId, 11 ConstId, EnumId, EnumVariantId, FieldId, FunctionId, ImplId, StaticId, StructId, TraitId,
12 TypeAliasId, TypeParamId, UnionId, 12 TypeAliasId, TypeParamId, UnionId,
13}; 13};
14 14
@@ -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, StructFieldId> = Key::new(); 28pub const TUPLE_FIELD: Key<ast::TupleFieldDef, FieldId> = Key::new();
29pub const RECORD_FIELD: Key<ast::RecordFieldDef, StructFieldId> = Key::new(); 29pub const RECORD_FIELD: Key<ast::RecordFieldDef, 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();
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 2d27bbdf8..518772e8a 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -133,12 +133,12 @@ pub struct EnumVariantId {
133pub type LocalEnumVariantId = Idx<adt::EnumVariantData>; 133pub type LocalEnumVariantId = Idx<adt::EnumVariantData>;
134 134
135#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 135#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
136pub struct StructFieldId { 136pub struct FieldId {
137 pub parent: VariantId, 137 pub parent: VariantId,
138 pub local_id: LocalStructFieldId, 138 pub local_id: LocalFieldId,
139} 139}
140 140
141pub type LocalStructFieldId = Idx<adt::StructFieldData>; 141pub type LocalFieldId = Idx<adt::FieldData>;
142 142
143#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 143#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
144pub struct ConstId(salsa::InternId); 144pub struct ConstId(salsa::InternId);
@@ -299,7 +299,7 @@ impl From<AssocItemId> for GenericDefId {
299#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 299#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
300pub enum AttrDefId { 300pub enum AttrDefId {
301 ModuleId(ModuleId), 301 ModuleId(ModuleId),
302 StructFieldId(StructFieldId), 302 FieldId(FieldId),
303 AdtId(AdtId), 303 AdtId(AdtId),
304 FunctionId(FunctionId), 304 FunctionId(FunctionId),
305 EnumVariantId(EnumVariantId), 305 EnumVariantId(EnumVariantId),
@@ -313,7 +313,7 @@ pub enum AttrDefId {
313 313
314impl_froms!( 314impl_froms!(
315 AttrDefId: ModuleId, 315 AttrDefId: ModuleId,
316 StructFieldId, 316 FieldId,
317 AdtId(StructId, EnumId, UnionId), 317 AdtId(StructId, EnumId, UnionId),
318 EnumVariantId, 318 EnumVariantId,
319 StaticId, 319 StaticId,