aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/adt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/adt.rs')
-rw-r--r--crates/ra_hir_def/src/adt.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs
index 8f41e55d2..a29c4d41e 100644
--- a/crates/ra_hir_def/src/adt.rs
+++ b/crates/ra_hir_def/src/adt.rs
@@ -8,7 +8,7 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
8 8
9use crate::{ 9use crate::{
10 db::DefDatabase2, type_ref::TypeRef, AstItemDef, EnumId, LocalEnumVariantId, 10 db::DefDatabase2, type_ref::TypeRef, AstItemDef, EnumId, LocalEnumVariantId,
11 LocalStructFieldId, StructId, UnionId, 11 LocalStructFieldId, StructOrUnionId,
12}; 12};
13 13
14/// Note that we use `StructData` for unions as well! 14/// Note that we use `StructData` for unions as well!
@@ -49,15 +49,11 @@ pub struct StructFieldData {
49} 49}
50 50
51impl StructData { 51impl StructData {
52 pub(crate) fn struct_data_query(db: &impl DefDatabase2, struct_: StructId) -> Arc<StructData> { 52 pub(crate) fn struct_data_query(
53 let src = struct_.source(db); 53 db: &impl DefDatabase2,
54 let name = src.ast.name().map(|n| n.as_name()); 54 id: StructOrUnionId,
55 let variant_data = VariantData::new(src.ast.kind()); 55 ) -> Arc<StructData> {
56 let variant_data = Arc::new(variant_data); 56 let src = id.source(db);
57 Arc::new(StructData { name, variant_data })
58 }
59 pub(crate) fn union_data_query(db: &impl DefDatabase2, struct_: UnionId) -> Arc<StructData> {
60 let src = struct_.source(db);
61 let name = src.ast.name().map(|n| n.as_name()); 57 let name = src.ast.name().map(|n| n.as_name());
62 let variant_data = VariantData::new(src.ast.kind()); 58 let variant_data = VariantData::new(src.ast.kind());
63 let variant_data = Arc::new(variant_data); 59 let variant_data = Arc::new(variant_data);