diff options
author | Aleksey Kladov <[email protected]> | 2019-11-21 12:56:27 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-21 12:56:27 +0000 |
commit | 36758f2767f173863039963c44791ac6c4080ab2 (patch) | |
tree | 5f90b034ccc56e423b69e3b166f9136c8c0a7b70 /crates/ra_hir_def/src | |
parent | c37d1c5b381365ce2d07dfe4b871e43995ccea2d (diff) |
Resimplify
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 29 |
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 | ||
510 | impl HasResolver for AdtId { | 510 | impl<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 | |||
525 | impl HasResolver for StructId { | ||
526 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | ||
527 | AdtId::from(self).resolver(db) | ||
528 | } | ||
529 | } | ||
530 | |||
531 | impl HasResolver for UnionId { | ||
532 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | ||
533 | AdtId::from(self).resolver(db) | ||
534 | } | ||
535 | } | ||
536 | |||
537 | impl HasResolver for EnumId { | ||
538 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | ||
539 | AdtId::from(self).resolver(db) | ||
540 | } | 523 | } |
541 | } | 524 | } |
542 | 525 | ||