From 590bd5f849cf257f499f6c7aa8da3dc4ffc7578f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 19 Dec 2018 18:04:17 +0300 Subject: workaround across-crate resolve bugs --- crates/ra_hir/src/module/nameres.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/module/nameres.rs b/crates/ra_hir/src/module/nameres.rs index 5540b827f..dc05c7112 100644 --- a/crates/ra_hir/src/module/nameres.rs +++ b/crates/ra_hir/src/module/nameres.rs @@ -252,7 +252,8 @@ where let krate = Crate::new(crate_id); for dep in krate.dependencies(self.db) { if let Some(module) = dep.krate.root_module(self.db)? { - self.add_module_item(&mut module_items, dep.name, module.module_id); + let def_id = module.def_id(self.db); + self.add_module_item(&mut module_items, dep.name, def_id); } } }; @@ -294,21 +295,21 @@ where // Populate modules for (name, module_id) in module_id.children(&self.module_tree) { - self.add_module_item(&mut module_items, name, module_id); + let def_loc = DefLoc { + kind: DefKind::Module, + source_root_id: self.source_root, + module_id, + source_item_id: module_id.source(&self.module_tree).0, + }; + let def_id = def_loc.id(self.db); + self.add_module_item(&mut module_items, name, def_id); } self.result.per_module.insert(module_id, module_items); Ok(()) } - fn add_module_item(&self, module_items: &mut ModuleScope, name: SmolStr, module_id: ModuleId) { - let def_loc = DefLoc { - kind: DefKind::Module, - source_root_id: self.source_root, - module_id, - source_item_id: module_id.source(&self.module_tree).0, - }; - let def_id = def_loc.id(self.db); + fn add_module_item(&self, module_items: &mut ModuleScope, name: SmolStr, def_id: DefId) { let resolution = Resolution { def_id: Some(def_id), import: None, @@ -329,7 +330,7 @@ where ImportKind::Named(ptr) => ptr, }; - let mut curr = match import.path.kind { + let mut curr: ModuleId = match import.path.kind { PathKind::Plain | PathKind::Self_ => module_id, PathKind::Super => { match module_id.parent(&self.module_tree) { @@ -357,8 +358,16 @@ where DefLoc { kind: DefKind::Module, module_id, + source_root_id, .. - } => module_id, + } => { + if source_root_id == self.source_root { + module_id + } else { + // FIXME: across crates resolve + return Ok(()); + } + } _ => return Ok(()), } } else { -- cgit v1.2.3