aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-09 12:37:49 +0000
committerGitHub <[email protected]>2019-11-09 12:37:49 +0000
commit9d786ea221b27fbdf7c7f7beea0290db448e0611 (patch)
tree312ae071afe742011c1e396d63123729e31f9815 /crates/ra_hir_def/src/lib.rs
parentdefc7ad772123a449f7cc384dd46d88c3a45fb53 (diff)
parent6294fd5ec9c6946bdd91f1274956c573f9f2a136 (diff)
Merge #2198
2198: Unfork struct and union ids r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r--crates/ra_hir_def/src/lib.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 63ed2a098..239317efe 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -205,26 +205,30 @@ impl AstItemDef<ast::FnDef> for FunctionId {
205} 205}
206 206
207#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 207#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
208pub struct StructId(salsa::InternId); 208pub struct StructOrUnionId(salsa::InternId);
209impl_intern_key!(StructId); 209impl_intern_key!(StructOrUnionId);
210impl AstItemDef<ast::StructDef> for StructId { 210impl AstItemDef<ast::StructDef> for StructOrUnionId {
211 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::StructDef>) -> Self { 211 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::StructDef>) -> Self {
212 db.intern_struct(loc) 212 db.intern_struct_or_union(loc)
213 } 213 }
214 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::StructDef> { 214 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::StructDef> {
215 db.lookup_intern_struct(self) 215 db.lookup_intern_struct_or_union(self)
216 } 216 }
217} 217}
218 218
219#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 219#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
220pub struct UnionId(salsa::InternId); 220pub struct StructId(pub StructOrUnionId);
221impl_intern_key!(UnionId); 221impl From<StructId> for StructOrUnionId {
222impl AstItemDef<ast::StructDef> for UnionId { 222 fn from(id: StructId) -> StructOrUnionId {
223 fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::StructDef>) -> Self { 223 id.0
224 db.intern_union(loc)
225 } 224 }
226 fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::StructDef> { 225}
227 db.lookup_intern_union(self) 226
227#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
228pub struct UnionId(pub StructOrUnionId);
229impl From<UnionId> for StructOrUnionId {
230 fn from(id: UnionId) -> StructOrUnionId {
231 id.0
228 } 232 }
229} 233}
230 234