aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r--crates/ra_hir_def/src/lib.rs32
1 files changed, 14 insertions, 18 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 8e8c2d749..5f11be114 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -141,30 +141,26 @@ impl Lookup for FunctionId {
141} 141}
142 142
143#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 143#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
144pub struct StructOrUnionId(salsa::InternId); 144pub struct StructId(salsa::InternId);
145impl_intern_key!(StructOrUnionId); 145impl_intern_key!(StructId);
146impl AstItemDef<ast::StructDef> for StructOrUnionId { 146impl AstItemDef<ast::StructDef> for StructId {
147 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::StructDef>) -> Self { 147 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::StructDef>) -> Self {
148 db.intern_struct_or_union(loc) 148 db.intern_struct(loc)
149 } 149 }
150 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::StructDef> { 150 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::StructDef> {
151 db.lookup_intern_struct_or_union(self) 151 db.lookup_intern_struct(self)
152 } 152 }
153} 153}
154 154
155#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 155#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
156pub struct StructId(pub StructOrUnionId); 156pub struct UnionId(salsa::InternId);
157impl From<StructId> for StructOrUnionId { 157impl_intern_key!(UnionId);
158 fn from(id: StructId) -> StructOrUnionId { 158impl AstItemDef<ast::UnionDef> for UnionId {
159 id.0 159 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::UnionDef>) -> Self {
160 db.intern_union(loc)
160 } 161 }
161} 162 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::UnionDef> {
162 163 db.lookup_intern_union(self)
163#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
164pub struct UnionId(pub StructOrUnionId);
165impl From<UnionId> for StructOrUnionId {
166 fn from(id: UnionId) -> StructOrUnionId {
167 id.0
168 } 164 }
169} 165}
170 166
@@ -485,8 +481,8 @@ impl HasModule for ConstLoc {
485impl HasModule for AdtId { 481impl HasModule for AdtId {
486 fn module(&self, db: &impl db::DefDatabase) -> ModuleId { 482 fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
487 match self { 483 match self {
488 AdtId::StructId(it) => it.0.module(db), 484 AdtId::StructId(it) => it.module(db),
489 AdtId::UnionId(it) => it.0.module(db), 485 AdtId::UnionId(it) => it.module(db),
490 AdtId::EnumId(it) => it.module(db), 486 AdtId::EnumId(it) => it.module(db),
491 } 487 }
492 } 488 }