mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
remove Cancelable from Crate API
This commit is contained in:
parent
c159e414b4
commit
8af9a18660
4 changed files with 10 additions and 10 deletions
|
@ -33,10 +33,10 @@ impl Crate {
|
||||||
pub fn crate_id(&self) -> CrateId {
|
pub fn crate_id(&self) -> CrateId {
|
||||||
self.crate_id
|
self.crate_id
|
||||||
}
|
}
|
||||||
pub fn dependencies(&self, db: &impl HirDatabase) -> Cancelable<Vec<CrateDependency>> {
|
pub fn dependencies(&self, db: &impl HirDatabase) -> Vec<CrateDependency> {
|
||||||
Ok(self.dependencies_impl(db))
|
self.dependencies_impl(db)
|
||||||
}
|
}
|
||||||
pub fn root_module(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
|
pub fn root_module(&self, db: &impl HirDatabase) -> Option<Module> {
|
||||||
self.root_module_impl(db)
|
self.root_module_impl(db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_db::{CrateId, Cancelable};
|
use ra_db::CrateId;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, SourceItemId,
|
HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, SourceItemId,
|
||||||
|
@ -20,7 +20,7 @@ impl Crate {
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
|
pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Option<Module> {
|
||||||
let crate_graph = db.crate_graph();
|
let crate_graph = db.crate_graph();
|
||||||
let file_id = crate_graph.crate_root(self.crate_id);
|
let file_id = crate_graph.crate_root(self.crate_id);
|
||||||
let source_root_id = db.file_source_root(file_id);
|
let source_root_id = db.file_source_root(file_id);
|
||||||
|
@ -31,7 +31,7 @@ impl Crate {
|
||||||
file_id,
|
file_id,
|
||||||
item_id: None,
|
item_id: None,
|
||||||
};
|
};
|
||||||
let module_id = ctry!(module_tree.find_module_by_source(source));
|
let module_id = module_tree.find_module_by_source(source)?;
|
||||||
|
|
||||||
let def_loc = DefLoc {
|
let def_loc = DefLoc {
|
||||||
kind: DefKind::Module,
|
kind: DefKind::Module,
|
||||||
|
@ -42,6 +42,6 @@ impl Crate {
|
||||||
let def_id = def_loc.id(db);
|
let def_id = def_loc.id(db);
|
||||||
|
|
||||||
let module = Module::new(def_id);
|
let module = Module::new(def_id);
|
||||||
Ok(Some(module))
|
Some(module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,8 +353,8 @@ where
|
||||||
if let Some(crate_id) = crate_graph.crate_id_for_crate_root(file_id.as_original_file())
|
if let Some(crate_id) = crate_graph.crate_id_for_crate_root(file_id.as_original_file())
|
||||||
{
|
{
|
||||||
let krate = Crate::new(crate_id);
|
let krate = Crate::new(crate_id);
|
||||||
for dep in krate.dependencies(self.db)? {
|
for dep in krate.dependencies(self.db) {
|
||||||
if let Some(module) = dep.krate.root_module(self.db)? {
|
if let Some(module) = dep.krate.root_module(self.db) {
|
||||||
let def_id = module.def_id;
|
let def_id = module.def_id;
|
||||||
self.add_module_item(
|
self.add_module_item(
|
||||||
&mut module_items,
|
&mut module_items,
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl CrateImplBlocks {
|
||||||
source_root_id,
|
source_root_id,
|
||||||
impls: FxHashMap::default(),
|
impls: FxHashMap::default(),
|
||||||
};
|
};
|
||||||
if let Some(module) = krate.root_module(db)? {
|
if let Some(module) = krate.root_module(db) {
|
||||||
crate_impl_blocks.collect_recursive(db, module)?;
|
crate_impl_blocks.collect_recursive(db, module)?;
|
||||||
}
|
}
|
||||||
Ok(Arc::new(crate_impl_blocks))
|
Ok(Arc::new(crate_impl_blocks))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue