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/resolver.rs42
1 files changed, 26 insertions, 16 deletions
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 4c859e497..9484a61d5 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -19,7 +19,7 @@ use crate::{
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, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, 21 GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId,
22 StructId, TraitId, TypeAliasId, TypeParamId, 22 StructId, TraitId, TypeAliasId, TypeParamId, VariantId,
23}; 23};
24 24
25#[derive(Debug, Clone, Default)] 25#[derive(Debug, Clone, Default)]
@@ -544,16 +544,6 @@ impl HasResolver for FunctionId {
544 } 544 }
545} 545}
546 546
547impl HasResolver for DefWithBodyId {
548 fn resolver(self, db: &impl DefDatabase) -> Resolver {
549 match self {
550 DefWithBodyId::ConstId(c) => c.resolver(db),
551 DefWithBodyId::FunctionId(f) => f.resolver(db),
552 DefWithBodyId::StaticId(s) => s.resolver(db),
553 }
554 }
555}
556
557impl HasResolver for ConstId { 547impl HasResolver for ConstId {
558 fn resolver(self, db: &impl DefDatabase) -> Resolver { 548 fn resolver(self, db: &impl DefDatabase) -> Resolver {
559 self.lookup(db).container.resolver(db) 549 self.lookup(db).container.resolver(db)
@@ -572,6 +562,25 @@ impl HasResolver for TypeAliasId {
572 } 562 }
573} 563}
574 564
565impl HasResolver for ImplId {
566 fn resolver(self, db: &impl DefDatabase) -> Resolver {
567 self.module(db)
568 .resolver(db)
569 .push_generic_params_scope(db, self.into())
570 .push_impl_block_scope(self)
571 }
572}
573
574impl HasResolver for DefWithBodyId {
575 fn resolver(self, db: &impl DefDatabase) -> Resolver {
576 match self {
577 DefWithBodyId::ConstId(c) => c.resolver(db),
578 DefWithBodyId::FunctionId(f) => f.resolver(db),
579 DefWithBodyId::StaticId(s) => s.resolver(db),
580 }
581 }
582}
583
575impl HasResolver for ContainerId { 584impl HasResolver for ContainerId {
576 fn resolver(self, db: &impl DefDatabase) -> Resolver { 585 fn resolver(self, db: &impl DefDatabase) -> Resolver {
577 match self { 586 match self {
@@ -596,11 +605,12 @@ impl HasResolver for GenericDefId {
596 } 605 }
597} 606}
598 607
599impl HasResolver for ImplId { 608impl HasResolver for VariantId {
600 fn resolver(self, db: &impl DefDatabase) -> Resolver { 609 fn resolver(self, db: &impl DefDatabase) -> Resolver {
601 self.module(db) 610 match self {
602 .resolver(db) 611 VariantId::EnumVariantId(it) => it.parent.resolver(db),
603 .push_generic_params_scope(db, self.into()) 612 VariantId::StructId(it) => it.resolver(db),
604 .push_impl_block_scope(self) 613 VariantId::UnionId(it) => it.resolver(db),
614 }
605 } 615 }
606} 616}