workaround across-crate resolve bugs

This commit is contained in:
Aleksey Kladov 2018-12-19 18:04:17 +03:00
parent 2fe41574a1
commit 590bd5f849

View file

@ -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 {