diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-09 12:37:49 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-09 12:37:49 +0000 |
commit | 9d786ea221b27fbdf7c7f7beea0290db448e0611 (patch) | |
tree | 312ae071afe742011c1e396d63123729e31f9815 /crates/ra_hir_def/src/lib.rs | |
parent | defc7ad772123a449f7cc384dd46d88c3a45fb53 (diff) | |
parent | 6294fd5ec9c6946bdd91f1274956c573f9f2a136 (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.rs | 28 |
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)] |
208 | pub struct StructId(salsa::InternId); | 208 | pub struct StructOrUnionId(salsa::InternId); |
209 | impl_intern_key!(StructId); | 209 | impl_intern_key!(StructOrUnionId); |
210 | impl AstItemDef<ast::StructDef> for StructId { | 210 | impl 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)] |
220 | pub struct UnionId(salsa::InternId); | 220 | pub struct StructId(pub StructOrUnionId); |
221 | impl_intern_key!(UnionId); | 221 | impl From<StructId> for StructOrUnionId { |
222 | impl 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)] | ||
228 | pub struct UnionId(pub StructOrUnionId); | ||
229 | impl From<UnionId> for StructOrUnionId { | ||
230 | fn from(id: UnionId) -> StructOrUnionId { | ||
231 | id.0 | ||
228 | } | 232 | } |
229 | } | 233 | } |
230 | 234 | ||