aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/resolve.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r--crates/ra_hir/src/resolve.rs39
1 files changed, 6 insertions, 33 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index b8e1b4dad..eca8e0596 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -16,7 +16,7 @@ use crate::{
16 expr::{ExprScopes, PatId, ScopeId}, 16 expr::{ExprScopes, PatId, ScopeId},
17 generics::{GenericParams, HasGenericParams}, 17 generics::{GenericParams, HasGenericParams},
18 Adt, Const, Container, DefWithBody, Enum, EnumVariant, Function, GenericDef, ImplBlock, Local, 18 Adt, Const, Container, DefWithBody, Enum, EnumVariant, Function, GenericDef, ImplBlock, Local,
19 MacroDef, Module, ModuleDef, PerNs, Static, Struct, Trait, TypeAlias, Union, 19 MacroDef, Module, ModuleDef, PerNs, Static, Struct, Trait, TypeAlias,
20}; 20};
21 21
22#[derive(Debug, Clone, Default)] 22#[derive(Debug, Clone, Default)]
@@ -505,40 +505,13 @@ impl HasResolver for Trait {
505 } 505 }
506} 506}
507 507
508impl HasResolver for Struct { 508impl<T: Into<Adt>> HasResolver for T {
509 fn resolver(self, db: &impl DefDatabase) -> Resolver { 509 fn resolver(self, db: &impl DefDatabase) -> Resolver {
510 self.module(db) 510 let def = self.into();
511 .resolver(db) 511 def.module(db)
512 .push_generic_params_scope(db, self.into())
513 .push_scope(Scope::AdtScope(self.into()))
514 }
515}
516
517impl HasResolver for Union {
518 fn resolver(self, db: &impl DefDatabase) -> Resolver {
519 self.module(db)
520 .resolver(db)
521 .push_generic_params_scope(db, self.into())
522 .push_scope(Scope::AdtScope(self.into()))
523 }
524}
525
526impl HasResolver for Enum {
527 fn resolver(self, db: &impl DefDatabase) -> Resolver {
528 self.module(db)
529 .resolver(db) 512 .resolver(db)
530 .push_generic_params_scope(db, self.into()) 513 .push_generic_params_scope(db, def.into())
531 .push_scope(Scope::AdtScope(self.into())) 514 .push_scope(Scope::AdtScope(def))
532 }
533}
534
535impl HasResolver for Adt {
536 fn resolver(self, db: &impl DefDatabase) -> Resolver {
537 match self {
538 Adt::Struct(it) => it.resolver(db),
539 Adt::Union(it) => it.resolver(db),
540 Adt::Enum(it) => it.resolver(db),
541 }
542 } 515 }
543} 516}
544 517