aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/adt.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-12 14:20:02 +0000
committerGitHub <[email protected]>2019-12-12 14:20:02 +0000
commitc213c3b36b7987504c6c3703b76a637dd0d01355 (patch)
tree36f9066ab25826f9401216d6ff371954eb9f447c /crates/ra_hir_def/src/adt.rs
parentd8dba7fbe587ba5fb6cfe939083ccd92c61f5827 (diff)
parent7a255a2f9381ba5886cacc48c1dd0420a739a55c (diff)
Merge #2539
2539: Remove old location infra r=matklad a=matklad 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.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs
index db3e63ef8..ec3d57d1a 100644
--- a/crates/ra_hir_def/src/adt.rs
+++ b/crates/ra_hir_def/src/adt.rs
@@ -11,8 +11,8 @@ use ra_arena::{map::ArenaMap, Arena};
11use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; 11use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
12 12
13use crate::{ 13use crate::{
14 db::DefDatabase, src::HasChildSource, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, 14 db::DefDatabase, src::HasChildSource, src::HasSource, trace::Trace, type_ref::TypeRef, EnumId,
15 LocalEnumVariantId, LocalStructFieldId, StructId, UnionId, VariantId, 15 LocalEnumVariantId, LocalStructFieldId, Lookup, StructId, UnionId, VariantId,
16}; 16};
17 17
18/// Note that we use `StructData` for unions as well! 18/// Note that we use `StructData` for unions as well!
@@ -50,14 +50,14 @@ pub struct StructFieldData {
50 50
51impl StructData { 51impl StructData {
52 pub(crate) fn struct_data_query(db: &impl DefDatabase, id: StructId) -> Arc<StructData> { 52 pub(crate) fn struct_data_query(db: &impl DefDatabase, id: StructId) -> Arc<StructData> {
53 let src = id.source(db); 53 let src = id.lookup(db).source(db);
54 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); 54 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
55 let variant_data = VariantData::new(src.value.kind()); 55 let variant_data = VariantData::new(src.value.kind());
56 let variant_data = Arc::new(variant_data); 56 let variant_data = Arc::new(variant_data);
57 Arc::new(StructData { name, variant_data }) 57 Arc::new(StructData { name, variant_data })
58 } 58 }
59 pub(crate) fn union_data_query(db: &impl DefDatabase, id: UnionId) -> Arc<StructData> { 59 pub(crate) fn union_data_query(db: &impl DefDatabase, id: UnionId) -> Arc<StructData> {
60 let src = id.source(db); 60 let src = id.lookup(db).source(db);
61 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); 61 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
62 let variant_data = VariantData::new( 62 let variant_data = VariantData::new(
63 src.value 63 src.value
@@ -72,7 +72,7 @@ impl StructData {
72 72
73impl EnumData { 73impl EnumData {
74 pub(crate) fn enum_data_query(db: &impl DefDatabase, e: EnumId) -> Arc<EnumData> { 74 pub(crate) fn enum_data_query(db: &impl DefDatabase, e: EnumId) -> Arc<EnumData> {
75 let src = e.source(db); 75 let src = e.lookup(db).source(db);
76 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); 76 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
77 let mut trace = Trace::new_for_arena(); 77 let mut trace = Trace::new_for_arena();
78 lower_enum(&mut trace, &src.value); 78 lower_enum(&mut trace, &src.value);
@@ -89,7 +89,7 @@ impl HasChildSource for EnumId {
89 type ChildId = LocalEnumVariantId; 89 type ChildId = LocalEnumVariantId;
90 type Value = ast::EnumVariant; 90 type Value = ast::EnumVariant;
91 fn child_source(&self, db: &impl DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { 91 fn child_source(&self, db: &impl DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> {
92 let src = self.source(db); 92 let src = self.lookup(db).source(db);
93 let mut trace = Trace::new_for_map(); 93 let mut trace = Trace::new_for_map();
94 lower_enum(&mut trace, &src.value); 94 lower_enum(&mut trace, &src.value);
95 src.with_value(trace.into_map()) 95 src.with_value(trace.into_map())
@@ -153,8 +153,8 @@ impl HasChildSource for VariantId {
153 let src = it.parent.child_source(db); 153 let src = it.parent.child_source(db);
154 src.map(|map| map[it.local_id].kind()) 154 src.map(|map| map[it.local_id].kind())
155 } 155 }
156 VariantId::StructId(it) => it.source(db).map(|it| it.kind()), 156 VariantId::StructId(it) => it.lookup(db).source(db).map(|it| it.kind()),
157 VariantId::UnionId(it) => it.source(db).map(|it| { 157 VariantId::UnionId(it) => it.lookup(db).source(db).map(|it| {
158 it.record_field_def_list() 158 it.record_field_def_list()
159 .map(ast::StructKind::Record) 159 .map(ast::StructKind::Record)
160 .unwrap_or(ast::StructKind::Unit) 160 .unwrap_or(ast::StructKind::Unit)