aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/lib.rs10
-rw-r--r--crates/ra_hir_def/src/resolver.rs12
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 e9d569778..8e8c2d749 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -482,6 +482,16 @@ impl HasModule for ConstLoc {
482 } 482 }
483} 483}
484 484
485impl HasModule for AdtId {
486 fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
487 match self {
488 AdtId::StructId(it) => it.0.module(db),
489 AdtId::UnionId(it) => it.0.module(db),
490 AdtId::EnumId(it) => it.module(db),
491 }
492 }
493}
494
485impl HasModule for StaticLoc { 495impl HasModule for StaticLoc {
486 fn module(&self, _db: &impl db::DefDatabase) -> ModuleId { 496 fn module(&self, _db: &impl db::DefDatabase) -> ModuleId {
487 self.container 497 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 {
503impl<T: Into<AdtId>> HasResolver for T { 503impl<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))