aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 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
484impl 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
484impl HasModule for StaticLoc { 494impl 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 {
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))