diff options
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 7ff0c43ae..a616f0ea5 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -2,25 +2,23 @@ | |||
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use hir_def::{ | 4 | use hir_def::{ |
5 | body::scope::{ExprScopes, ScopeId}, | ||
5 | builtin_type::BuiltinType, | 6 | builtin_type::BuiltinType, |
6 | db::DefDatabase2, | 7 | db::DefDatabase2, |
7 | expr::ExprId, | 8 | expr::{ExprId, PatId}, |
8 | generics::GenericParams, | 9 | generics::GenericParams, |
9 | nameres::CrateDefMap, | 10 | nameres::{per_ns::PerNs, CrateDefMap}, |
10 | path::{Path, PathKind}, | 11 | path::{Path, PathKind}, |
11 | AdtId, AstItemDef, ConstId, ContainerId, CrateModuleId, DefWithBodyId, EnumId, EnumVariantId, | 12 | AdtId, AstItemDef, ConstId, ContainerId, CrateModuleId, DefWithBodyId, EnumId, EnumVariantId, |
12 | FunctionId, GenericDefId, ImplId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId, | 13 | FunctionId, GenericDefId, ImplId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId, |
13 | TypeAliasId, UnionId, | 14 | TypeAliasId, UnionId, |
14 | }; | 15 | }; |
15 | use hir_expand::name::{self, Name}; | 16 | use hir_expand::{ |
16 | use rustc_hash::FxHashSet; | 17 | name::{self, Name}, |
17 | 18 | MacroDefId, | |
18 | use crate::{ | ||
19 | code_model::Crate, | ||
20 | db::HirDatabase, | ||
21 | expr::{ExprScopes, PatId, ScopeId}, | ||
22 | DefWithBody, GenericDef, MacroDef, PerNs, | ||
23 | }; | 19 | }; |
20 | use ra_db::CrateId; | ||
21 | use rustc_hash::FxHashSet; | ||
24 | 22 | ||
25 | #[derive(Debug, Clone, Default)] | 23 | #[derive(Debug, Clone, Default)] |
26 | pub(crate) struct Resolver { | 24 | pub(crate) struct Resolver { |
@@ -318,9 +316,9 @@ impl Resolver { | |||
318 | &self, | 316 | &self, |
319 | db: &impl DefDatabase2, | 317 | db: &impl DefDatabase2, |
320 | path: &Path, | 318 | path: &Path, |
321 | ) -> Option<MacroDef> { | 319 | ) -> Option<MacroDefId> { |
322 | let (item_map, module) = self.module()?; | 320 | let (item_map, module) = self.module()?; |
323 | item_map.resolve_path(db, module, path).0.get_macros().map(MacroDef::from) | 321 | item_map.resolve_path(db, module, path).0.get_macros() |
324 | } | 322 | } |
325 | 323 | ||
326 | pub(crate) fn process_all_names( | 324 | pub(crate) fn process_all_names( |
@@ -355,8 +353,8 @@ impl Resolver { | |||
355 | }) | 353 | }) |
356 | } | 354 | } |
357 | 355 | ||
358 | pub(crate) fn krate(&self) -> Option<Crate> { | 356 | pub(crate) fn krate(&self) -> Option<CrateId> { |
359 | self.module().map(|t| Crate { crate_id: t.0.krate() }) | 357 | self.module().map(|t| t.0.krate()) |
360 | } | 358 | } |
361 | 359 | ||
362 | pub(crate) fn where_predicates_in_scope<'a>( | 360 | pub(crate) fn where_predicates_in_scope<'a>( |
@@ -484,7 +482,7 @@ impl Scope { | |||
484 | 482 | ||
485 | // needs arbitrary_self_types to be a method... or maybe move to the def? | 483 | // needs arbitrary_self_types to be a method... or maybe move to the def? |
486 | pub(crate) fn resolver_for_expr( | 484 | pub(crate) fn resolver_for_expr( |
487 | db: &impl HirDatabase, | 485 | db: &impl DefDatabase2, |
488 | owner: DefWithBodyId, | 486 | owner: DefWithBodyId, |
489 | expr_id: ExprId, | 487 | expr_id: ExprId, |
490 | ) -> Resolver { | 488 | ) -> Resolver { |
@@ -493,7 +491,7 @@ pub(crate) fn resolver_for_expr( | |||
493 | } | 491 | } |
494 | 492 | ||
495 | pub(crate) fn resolver_for_scope( | 493 | pub(crate) fn resolver_for_scope( |
496 | db: &impl HirDatabase, | 494 | db: &impl DefDatabase2, |
497 | owner: DefWithBodyId, | 495 | owner: DefWithBodyId, |
498 | scope_id: Option<ScopeId>, | 496 | scope_id: Option<ScopeId>, |
499 | ) -> Resolver { | 497 | ) -> Resolver { |
@@ -623,15 +621,3 @@ impl HasResolver for ImplId { | |||
623 | .push_impl_block_scope(self) | 621 | .push_impl_block_scope(self) |
624 | } | 622 | } |
625 | } | 623 | } |
626 | |||
627 | impl HasResolver for GenericDef { | ||
628 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | ||
629 | GenericDefId::from(self).resolver(db) | ||
630 | } | ||
631 | } | ||
632 | |||
633 | impl HasResolver for DefWithBody { | ||
634 | fn resolver(self, db: &impl DefDatabase2) -> Resolver { | ||
635 | DefWithBodyId::from(self).resolver(db) | ||
636 | } | ||
637 | } | ||