remove Cancelable from Module API, part 2

This commit is contained in:
Aleksey Kladov 2019-01-15 18:30:58 +03:00
parent ca52cf1ecd
commit c159e414b4
7 changed files with 28 additions and 33 deletions

View file

@ -97,14 +97,14 @@ impl Module {
}
/// Returns the crate this module is part of.
pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> {
pub fn krate(&self, db: &impl HirDatabase) -> Option<Crate> {
self.krate_impl(db)
}
/// Topmost parent of this module. Every module has a `crate_root`, but some
/// might be missing `krate`. This can happen if a module's file is not included
/// in the module tree of any target in Cargo.toml.
pub fn crate_root(&self, db: &impl HirDatabase) -> Cancelable<Module> {
pub fn crate_root(&self, db: &impl HirDatabase) -> Module {
self.crate_root_impl(db)
}
@ -114,23 +114,23 @@ impl Module {
}
/// Iterates over all child modules.
pub fn children(&self, db: &impl HirDatabase) -> Cancelable<impl Iterator<Item = Module>> {
pub fn children(&self, db: &impl HirDatabase) -> impl Iterator<Item = Module> {
self.children_impl(db)
}
/// Finds a parent module.
pub fn parent(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
pub fn parent(&self, db: &impl HirDatabase) -> Option<Module> {
self.parent_impl(db)
}
pub fn path_to_root(&self, db: &impl HirDatabase) -> Cancelable<Vec<Module>> {
pub fn path_to_root(&self, db: &impl HirDatabase) -> Vec<Module> {
let mut res = vec![self.clone()];
let mut curr = self.clone();
while let Some(next) = curr.parent(db)? {
while let Some(next) = curr.parent(db) {
res.push(next.clone());
curr = next
}
Ok(res)
res
}
/// Returns a `ModuleScope`: a set of items, visible in this module.