diff options
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 9 |
2 files changed, 15 insertions, 9 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index af8ac064c..693c3fe8e 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -8,7 +8,7 @@ use ra_syntax::ast; | |||
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef, | 10 | Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef, |
11 | DefDatabase, HirFileId, Name, Path, | 11 | DefDatabase, HirFileId, Name, Path, AstDatabase, |
12 | KnownName, | 12 | KnownName, |
13 | nameres::{ | 13 | nameres::{ |
14 | Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode, | 14 | Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode, |
@@ -20,7 +20,10 @@ use crate::{ | |||
20 | AstId, | 20 | AstId, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 23 | pub(super) fn collect_defs( |
24 | db: &(impl DefDatabase + AstDatabase), | ||
25 | mut def_map: CrateDefMap, | ||
26 | ) -> CrateDefMap { | ||
24 | // populate external prelude | 27 | // populate external prelude |
25 | for dep in def_map.krate.dependencies(db) { | 28 | for dep in def_map.krate.dependencies(db) { |
26 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.krate); | 29 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.krate); |
@@ -93,7 +96,7 @@ struct DefCollector<DB> { | |||
93 | 96 | ||
94 | impl<'a, DB> DefCollector<&'a DB> | 97 | impl<'a, DB> DefCollector<&'a DB> |
95 | where | 98 | where |
96 | DB: DefDatabase, | 99 | DB: DefDatabase + AstDatabase, |
97 | { | 100 | { |
98 | fn collect(&mut self) { | 101 | fn collect(&mut self) { |
99 | let crate_graph = self.db.crate_graph(); | 102 | let crate_graph = self.db.crate_graph(); |
@@ -470,7 +473,7 @@ struct ModCollector<'a, D> { | |||
470 | 473 | ||
471 | impl<DB> ModCollector<'_, &'_ mut DefCollector<&'_ DB>> | 474 | impl<DB> ModCollector<'_, &'_ mut DefCollector<&'_ DB>> |
472 | where | 475 | where |
473 | DB: DefDatabase, | 476 | DB: DefDatabase + AstDatabase, |
474 | { | 477 | { |
475 | fn collect(&mut self, items: &[raw::RawItem]) { | 478 | fn collect(&mut self, items: &[raw::RawItem]) { |
476 | for item in items { | 479 | for item in items { |
@@ -615,7 +618,7 @@ fn is_macro_rules(path: &Path) -> bool { | |||
615 | } | 618 | } |
616 | 619 | ||
617 | fn resolve_submodule( | 620 | fn resolve_submodule( |
618 | db: &impl DefDatabase, | 621 | db: &(impl DefDatabase + AstDatabase), |
619 | file_id: HirFileId, | 622 | file_id: HirFileId, |
620 | name: &Name, | 623 | name: &Name, |
621 | is_root: bool, | 624 | is_root: bool, |
@@ -658,7 +661,7 @@ mod tests { | |||
658 | use rustc_hash::FxHashSet; | 661 | use rustc_hash::FxHashSet; |
659 | 662 | ||
660 | fn do_collect_defs( | 663 | fn do_collect_defs( |
661 | db: &impl DefDatabase, | 664 | db: &(impl DefDatabase + AstDatabase), |
662 | def_map: CrateDefMap, | 665 | def_map: CrateDefMap, |
663 | monitor: MacroStackMonitor, | 666 | monitor: MacroStackMonitor, |
664 | ) -> CrateDefMap { | 667 | ) -> CrateDefMap { |
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 1b4dcbb7a..21935dbb9 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -7,7 +7,7 @@ use ra_syntax::{ | |||
7 | ast::{self, NameOwner, AttrsOwner}, | 7 | ast::{self, NameOwner, AttrsOwner}, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, AstIdMap, FileAstId, Either}; | 10 | use crate::{DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, AstIdMap, FileAstId, Either, AstDatabase}; |
11 | 11 | ||
12 | /// `RawItems` is a set of top-level items in a file (except for impls). | 12 | /// `RawItems` is a set of top-level items in a file (except for impls). |
13 | /// | 13 | /// |
@@ -56,12 +56,15 @@ impl ImportSourceMap { | |||
56 | } | 56 | } |
57 | 57 | ||
58 | impl RawItems { | 58 | impl RawItems { |
59 | pub(crate) fn raw_items_query(db: &impl DefDatabase, file_id: HirFileId) -> Arc<RawItems> { | 59 | pub(crate) fn raw_items_query( |
60 | db: &(impl DefDatabase + AstDatabase), | ||
61 | file_id: HirFileId, | ||
62 | ) -> Arc<RawItems> { | ||
60 | db.raw_items_with_source_map(file_id).0 | 63 | db.raw_items_with_source_map(file_id).0 |
61 | } | 64 | } |
62 | 65 | ||
63 | pub(crate) fn raw_items_with_source_map_query( | 66 | pub(crate) fn raw_items_with_source_map_query( |
64 | db: &impl DefDatabase, | 67 | db: &(impl DefDatabase + AstDatabase), |
65 | file_id: HirFileId, | 68 | file_id: HirFileId, |
66 | ) -> (Arc<RawItems>, Arc<ImportSourceMap>) { | 69 | ) -> (Arc<RawItems>, Arc<ImportSourceMap>) { |
67 | let mut collector = RawItemsCollector { | 70 | let mut collector = RawItemsCollector { |