diff options
author | Aleksey Kladov <[email protected]> | 2019-11-20 14:49:57 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-20 14:50:02 +0000 |
commit | ee95a35664e6fe9153f6324cfc57872ca365887c (patch) | |
tree | 3f13501f0e73fee374a0df05fb55614311559f15 /crates/ra_hir_def/src/lib.rs | |
parent | 64c21ed19594b323e72605ba8c5dd4c6eee433f6 (diff) |
Don't duplicate ContainerId type
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 6052370b4..da6506fcd 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -201,7 +201,7 @@ impl_intern_key!(FunctionId); | |||
201 | 201 | ||
202 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 202 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
203 | pub struct FunctionLoc { | 203 | pub struct FunctionLoc { |
204 | pub container: FunctionContainerId, | 204 | pub container: ContainerId, |
205 | pub ast_id: AstId<ast::FnDef>, | 205 | pub ast_id: AstId<ast::FnDef>, |
206 | } | 206 | } |
207 | 207 | ||
@@ -220,13 +220,6 @@ impl Lookup for FunctionId { | |||
220 | } | 220 | } |
221 | 221 | ||
222 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 222 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
223 | pub enum FunctionContainerId { | ||
224 | ModuleId(ModuleId), | ||
225 | ImplId(ImplId), | ||
226 | TraitId(TraitId), | ||
227 | } | ||
228 | |||
229 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
230 | pub struct StructOrUnionId(salsa::InternId); | 223 | pub struct StructOrUnionId(salsa::InternId); |
231 | impl_intern_key!(StructOrUnionId); | 224 | impl_intern_key!(StructOrUnionId); |
232 | impl AstItemDef<ast::StructDef> for StructOrUnionId { | 225 | impl AstItemDef<ast::StructDef> for StructOrUnionId { |
@@ -335,7 +328,7 @@ impl_intern_key!(TypeAliasId); | |||
335 | 328 | ||
336 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 329 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
337 | pub struct TypeAliasLoc { | 330 | pub struct TypeAliasLoc { |
338 | pub container: TypeAliasContainerId, | 331 | pub container: ContainerId, |
339 | pub ast_id: AstId<ast::TypeAliasDef>, | 332 | pub ast_id: AstId<ast::TypeAliasDef>, |
340 | } | 333 | } |
341 | 334 | ||
@@ -354,13 +347,6 @@ impl Lookup for TypeAliasId { | |||
354 | } | 347 | } |
355 | 348 | ||
356 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 349 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
357 | pub enum TypeAliasContainerId { | ||
358 | ModuleId(ModuleId), | ||
359 | ImplId(ImplId), | ||
360 | TraitId(TraitId), | ||
361 | } | ||
362 | |||
363 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
364 | pub struct ImplId(salsa::InternId); | 350 | pub struct ImplId(salsa::InternId); |
365 | impl_intern_key!(ImplId); | 351 | impl_intern_key!(ImplId); |
366 | impl AstItemDef<ast::ImplBlock> for ImplId { | 352 | impl AstItemDef<ast::ImplBlock> for ImplId { |
@@ -391,6 +377,13 @@ macro_rules! impl_froms { | |||
391 | } | 377 | } |
392 | } | 378 | } |
393 | 379 | ||
380 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
381 | pub enum ContainerId { | ||
382 | ModuleId(ModuleId), | ||
383 | ImplId(ImplId), | ||
384 | TraitId(TraitId), | ||
385 | } | ||
386 | |||
394 | /// A Data Type | 387 | /// A Data Type |
395 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 388 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
396 | pub enum AdtId { | 389 | pub enum AdtId { |
@@ -488,9 +481,9 @@ pub trait HasModule { | |||
488 | impl HasModule for FunctionLoc { | 481 | impl HasModule for FunctionLoc { |
489 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { | 482 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { |
490 | match self.container { | 483 | match self.container { |
491 | FunctionContainerId::ModuleId(it) => it, | 484 | ContainerId::ModuleId(it) => it, |
492 | FunctionContainerId::ImplId(it) => it.module(db), | 485 | ContainerId::ImplId(it) => it.module(db), |
493 | FunctionContainerId::TraitId(it) => it.module(db), | 486 | ContainerId::TraitId(it) => it.module(db), |
494 | } | 487 | } |
495 | } | 488 | } |
496 | } | 489 | } |
@@ -498,9 +491,9 @@ impl HasModule for FunctionLoc { | |||
498 | impl HasModule for TypeAliasLoc { | 491 | impl HasModule for TypeAliasLoc { |
499 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { | 492 | fn module(&self, db: &impl db::DefDatabase2) -> ModuleId { |
500 | match self.container { | 493 | match self.container { |
501 | TypeAliasContainerId::ModuleId(it) => it, | 494 | ContainerId::ModuleId(it) => it, |
502 | TypeAliasContainerId::ImplId(it) => it.module(db), | 495 | ContainerId::ImplId(it) => it.module(db), |
503 | TypeAliasContainerId::TraitId(it) => it.module(db), | 496 | ContainerId::TraitId(it) => it.module(db), |
504 | } | 497 | } |
505 | } | 498 | } |
506 | } | 499 | } |