aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres/collector.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-26 19:51:29 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-26 19:51:29 +0100
commit5536a249145fc67c415ad48738e62fc2a9e848ff (patch)
tree0dacb8b02ca5b705123a022893512c61d3c8c718 /crates/ra_hir/src/nameres/collector.rs
parent203d5dd0d0092b505db9efcff377fea154cbfe11 (diff)
parent6e2369938a6f5214680dcc0f4bb58cdb20dc1015 (diff)
Merge #1447
1447: make sure that CrateDefMap is independent from syntax r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres/collector.rs')
-rw-r--r--crates/ra_hir/src/nameres/collector.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index b74dc33b1..ef4d1ed70 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -7,7 +7,7 @@ use ra_syntax::ast;
7 7
8use crate::{ 8use crate::{
9 Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef, 9 Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef,
10 DefDatabase, HirFileId, Name, Path, AstDatabase, 10 DefDatabase, HirFileId, Name, Path,
11 KnownName, AstId, 11 KnownName, AstId,
12 nameres::{ 12 nameres::{
13 Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode, 13 Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode,
@@ -19,10 +19,7 @@ use crate::{
19 either::Either, 19 either::Either,
20}; 20};
21 21
22pub(super) fn collect_defs( 22pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
23 db: &(impl DefDatabase + AstDatabase),
24 mut def_map: CrateDefMap,
25) -> CrateDefMap {
26 // populate external prelude 23 // populate external prelude
27 for dep in def_map.krate.dependencies(db) { 24 for dep in def_map.krate.dependencies(db) {
28 log::debug!("crate dep {:?} -> {:?}", dep.name, dep.krate); 25 log::debug!("crate dep {:?} -> {:?}", dep.name, dep.krate);
@@ -95,7 +92,7 @@ struct DefCollector<DB> {
95 92
96impl<'a, DB> DefCollector<&'a DB> 93impl<'a, DB> DefCollector<&'a DB>
97where 94where
98 DB: DefDatabase + AstDatabase, 95 DB: DefDatabase,
99{ 96{
100 fn collect(&mut self) { 97 fn collect(&mut self) {
101 let crate_graph = self.db.crate_graph(); 98 let crate_graph = self.db.crate_graph();
@@ -465,7 +462,7 @@ where
465 ModCollector { def_collector: &mut *self, file_id, module_id, raw_items: &raw_items } 462 ModCollector { def_collector: &mut *self, file_id, module_id, raw_items: &raw_items }
466 .collect(raw_items.items()); 463 .collect(raw_items.items());
467 } else { 464 } else {
468 log::error!("Too deep macro expansion: {}", macro_call_id.debug_dump(self.db)); 465 log::error!("Too deep macro expansion: {:?}", macro_call_id);
469 self.def_map.poison_macros.insert(macro_def_id); 466 self.def_map.poison_macros.insert(macro_def_id);
470 } 467 }
471 468
@@ -487,7 +484,7 @@ struct ModCollector<'a, D> {
487 484
488impl<DB> ModCollector<'_, &'_ mut DefCollector<&'_ DB>> 485impl<DB> ModCollector<'_, &'_ mut DefCollector<&'_ DB>>
489where 486where
490 DB: DefDatabase + AstDatabase, 487 DB: DefDatabase,
491{ 488{
492 fn collect(&mut self, items: &[raw::RawItem]) { 489 fn collect(&mut self, items: &[raw::RawItem]) {
493 for item in items { 490 for item in items {
@@ -632,7 +629,7 @@ fn is_macro_rules(path: &Path) -> bool {
632} 629}
633 630
634fn resolve_submodule( 631fn resolve_submodule(
635 db: &(impl DefDatabase + AstDatabase), 632 db: &impl DefDatabase,
636 file_id: HirFileId, 633 file_id: HirFileId,
637 name: &Name, 634 name: &Name,
638 is_root: bool, 635 is_root: bool,
@@ -675,7 +672,7 @@ mod tests {
675 use rustc_hash::FxHashSet; 672 use rustc_hash::FxHashSet;
676 673
677 fn do_collect_defs( 674 fn do_collect_defs(
678 db: &(impl DefDatabase + AstDatabase), 675 db: &impl DefDatabase,
679 def_map: CrateDefMap, 676 def_map: CrateDefMap,
680 monitor: MacroStackMonitor, 677 monitor: MacroStackMonitor,
681 ) -> CrateDefMap { 678 ) -> CrateDefMap {