aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-19 15:04:17 +0000
committerAleksey Kladov <[email protected]>2018-12-20 09:15:38 +0000
commit590bd5f849cf257f499f6c7aa8da3dc4ffc7578f (patch)
treea521356e3b9be9f97fe94e252ea043e44a2c08d9 /crates/ra_hir/src
parent2fe41574a1695a6608d738f40ec51bc61fc7604a (diff)
workaround across-crate resolve bugs
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/module/nameres.rs33
1 files changed, 21 insertions, 12 deletions
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
252 let krate = Crate::new(crate_id); 252 let krate = Crate::new(crate_id);
253 for dep in krate.dependencies(self.db) { 253 for dep in krate.dependencies(self.db) {
254 if let Some(module) = dep.krate.root_module(self.db)? { 254 if let Some(module) = dep.krate.root_module(self.db)? {
255 self.add_module_item(&mut module_items, dep.name, module.module_id); 255 let def_id = module.def_id(self.db);
256 self.add_module_item(&mut module_items, dep.name, def_id);
256 } 257 }
257 } 258 }
258 }; 259 };
@@ -294,21 +295,21 @@ where
294 295
295 // Populate modules 296 // Populate modules
296 for (name, module_id) in module_id.children(&self.module_tree) { 297 for (name, module_id) in module_id.children(&self.module_tree) {
297 self.add_module_item(&mut module_items, name, module_id); 298 let def_loc = DefLoc {
299 kind: DefKind::Module,
300 source_root_id: self.source_root,
301 module_id,
302 source_item_id: module_id.source(&self.module_tree).0,
303 };
304 let def_id = def_loc.id(self.db);
305 self.add_module_item(&mut module_items, name, def_id);
298 } 306 }
299 307
300 self.result.per_module.insert(module_id, module_items); 308 self.result.per_module.insert(module_id, module_items);
301 Ok(()) 309 Ok(())
302 } 310 }
303 311
304 fn add_module_item(&self, module_items: &mut ModuleScope, name: SmolStr, module_id: ModuleId) { 312 fn add_module_item(&self, module_items: &mut ModuleScope, name: SmolStr, def_id: DefId) {
305 let def_loc = DefLoc {
306 kind: DefKind::Module,
307 source_root_id: self.source_root,
308 module_id,
309 source_item_id: module_id.source(&self.module_tree).0,
310 };
311 let def_id = def_loc.id(self.db);
312 let resolution = Resolution { 313 let resolution = Resolution {
313 def_id: Some(def_id), 314 def_id: Some(def_id),
314 import: None, 315 import: None,
@@ -329,7 +330,7 @@ where
329 ImportKind::Named(ptr) => ptr, 330 ImportKind::Named(ptr) => ptr,
330 }; 331 };
331 332
332 let mut curr = match import.path.kind { 333 let mut curr: ModuleId = match import.path.kind {
333 PathKind::Plain | PathKind::Self_ => module_id, 334 PathKind::Plain | PathKind::Self_ => module_id,
334 PathKind::Super => { 335 PathKind::Super => {
335 match module_id.parent(&self.module_tree) { 336 match module_id.parent(&self.module_tree) {
@@ -357,8 +358,16 @@ where
357 DefLoc { 358 DefLoc {
358 kind: DefKind::Module, 359 kind: DefKind::Module,
359 module_id, 360 module_id,
361 source_root_id,
360 .. 362 ..
361 } => module_id, 363 } => {
364 if source_root_id == self.source_root {
365 module_id
366 } else {
367 // FIXME: across crates resolve
368 return Ok(());
369 }
370 }
362 _ => return Ok(()), 371 _ => return Ok(()),
363 } 372 }
364 } else { 373 } else {