aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_def/src/resolver.rs29
1 files changed, 6 insertions, 23 deletions
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 840785baa..1bc9c1760 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -18,7 +18,7 @@ use crate::{
18 path::{Path, PathKind}, 18 path::{Path, PathKind},
19 AdtId, AstItemDef, ConstId, ContainerId, CrateModuleId, DefWithBodyId, EnumId, EnumVariantId, 19 AdtId, AstItemDef, ConstId, ContainerId, CrateModuleId, DefWithBodyId, EnumId, EnumVariantId,
20 FunctionId, GenericDefId, ImplId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId, 20 FunctionId, GenericDefId, ImplId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId,
21 TypeAliasId, UnionId, 21 TypeAliasId,
22}; 22};
23 23
24#[derive(Debug, Clone, Default)] 24#[derive(Debug, Clone, Default)]
@@ -507,9 +507,10 @@ impl HasResolver for TraitId {
507 } 507 }
508} 508}
509 509
510impl HasResolver for AdtId { 510impl<T: Into<AdtId>> HasResolver for T {
511 fn resolver(self, db: &impl DefDatabase2) -> Resolver { 511 fn resolver(self, db: &impl DefDatabase2) -> Resolver {
512 let module = match self { 512 let def = self.into();
513 let module = match def {
513 AdtId::StructId(it) => it.0.module(db), 514 AdtId::StructId(it) => it.0.module(db),
514 AdtId::UnionId(it) => it.0.module(db), 515 AdtId::UnionId(it) => it.0.module(db),
515 AdtId::EnumId(it) => it.module(db), 516 AdtId::EnumId(it) => it.module(db),
@@ -517,26 +518,8 @@ impl HasResolver for AdtId {
517 518
518 module 519 module
519 .resolver(db) 520 .resolver(db)
520 .push_generic_params_scope(db, self.into()) 521 .push_generic_params_scope(db, def.into())
521 .push_scope(Scope::AdtScope(self.into())) 522 .push_scope(Scope::AdtScope(def))
522 }
523}
524
525impl HasResolver for StructId {
526 fn resolver(self, db: &impl DefDatabase2) -> Resolver {
527 AdtId::from(self).resolver(db)
528 }
529}
530
531impl HasResolver for UnionId {
532 fn resolver(self, db: &impl DefDatabase2) -> Resolver {
533 AdtId::from(self).resolver(db)
534 }
535}
536
537impl HasResolver for EnumId {
538 fn resolver(self, db: &impl DefDatabase2) -> Resolver {
539 AdtId::from(self).resolver(db)
540 } 523 }
541} 524}
542 525