diff options
author | Aleksey Kladov <[email protected]> | 2019-11-24 19:47:58 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-24 19:48:37 +0000 |
commit | a0e1dbb45038440ddfe0c53c99d16b7f50c2d2a3 (patch) | |
tree | 25be7f35fc0cdbde880600660d9c98b440920931 | |
parent | 586acef5283e78f19e5e9daf4e8aac40e2a9ff16 (diff) |
Implement HasModule for AdtId
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 12 |
2 files changed, 13 insertions, 9 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index f63c3dd64..5bc9ffc0d 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -481,6 +481,16 @@ impl HasModule for ConstLoc { | |||
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | impl HasModule for AdtId { | ||
485 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { | ||
486 | match self { | ||
487 | AdtId::StructId(it) => it.0.module(db), | ||
488 | AdtId::UnionId(it) => it.0.module(db), | ||
489 | AdtId::EnumId(it) => it.module(db), | ||
490 | } | ||
491 | } | ||
492 | } | ||
493 | |||
484 | impl HasModule for StaticLoc { | 494 | impl HasModule for StaticLoc { |
485 | fn module(&self, _db: &impl db::DefDatabase) -> ModuleId { | 495 | fn module(&self, _db: &impl db::DefDatabase) -> ModuleId { |
486 | self.container | 496 | self.container |
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 1f8887c6b..95b3c926d 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -18,8 +18,8 @@ use crate::{ | |||
18 | path::{Path, PathKind}, | 18 | path::{Path, PathKind}, |
19 | per_ns::PerNs, | 19 | per_ns::PerNs, |
20 | AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, | 20 | AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, |
21 | GenericDefId, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, | 21 | GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, |
22 | TraitId, TypeAliasId, | 22 | StructId, TraitId, TypeAliasId, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | #[derive(Debug, Clone, Default)] | 25 | #[derive(Debug, Clone, Default)] |
@@ -503,13 +503,7 @@ impl HasResolver for TraitId { | |||
503 | impl<T: Into<AdtId>> HasResolver for T { | 503 | impl<T: Into<AdtId>> HasResolver for T { |
504 | fn resolver(self, db: &impl DefDatabase) -> Resolver { | 504 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
505 | let def = self.into(); | 505 | let def = self.into(); |
506 | let module = match def { | 506 | def.module(db) |
507 | AdtId::StructId(it) => it.0.module(db), | ||
508 | AdtId::UnionId(it) => it.0.module(db), | ||
509 | AdtId::EnumId(it) => it.module(db), | ||
510 | }; | ||
511 | |||
512 | module | ||
513 | .resolver(db) | 507 | .resolver(db) |
514 | .push_generic_params_scope(db, def.into()) | 508 | .push_generic_params_scope(db, def.into()) |
515 | .push_scope(Scope::AdtScope(def)) | 509 | .push_scope(Scope::AdtScope(def)) |