From f1367e0370d5de5cba13c853c7df5f0c5a0edf59 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jan 2019 18:50:16 +0300 Subject: remove Cancelable from navigation target --- crates/ra_hir/src/code_model_api.rs | 4 ++-- crates/ra_hir/src/code_model_impl/module.rs | 2 +- crates/ra_hir/src/expr.rs | 4 ++-- crates/ra_hir/src/ids.rs | 7 +++---- crates/ra_hir/src/ty.rs | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index f6d1d6b23..f28e077c6 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -297,8 +297,8 @@ impl Function { self.def_id } - pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc)> { - Ok(def_id_to_ast(db, self.def_id)) + pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc) { + def_id_to_ast(db, self.def_id) } pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Cancelable> { diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index f27523753..331b0500e 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs @@ -148,7 +148,7 @@ impl Module { } else { return Ok(PerNs::none()); }; - let module = match curr.resolve(db)? { + let module = match curr.resolve(db) { Def::Module(it) => it, Def::Enum(e) => { if segments.len() == idx + 1 { diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 5081466a2..a1e8da348 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -832,10 +832,10 @@ pub(crate) fn body_syntax_mapping( db: &impl HirDatabase, def_id: DefId, ) -> Cancelable> { - let def = def_id.resolve(db)?; + let def = def_id.resolve(db); let body_syntax_mapping = match def { - Def::Function(f) => collect_fn_body_syntax(&f.source(db)?.1), + Def::Function(f) => collect_fn_body_syntax(&f.source(db).1), // TODO: consts, etc. _ => panic!("Trying to get body for item type without body"), }; diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 7b572061a..3cbf8070f 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -159,9 +159,9 @@ impl DefId { db.as_ref().id2loc(self) } - pub fn resolve(self, db: &impl HirDatabase) -> Cancelable { + pub fn resolve(self, db: &impl HirDatabase) -> Def { let loc = self.loc(db); - let res = match loc.kind { + match loc.kind { DefKind::Module => { let module = Module::from_module_id(db, loc.source_root_id, loc.module_id); Def::Module(module) @@ -195,8 +195,7 @@ impl DefId { DefKind::StructCtor => Def::Item, DefKind::Item => Def::Item, - }; - Ok(res) + } } pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreeArc) { diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index b0642d905..3607969ed 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -481,7 +481,7 @@ pub(crate) fn type_for_enum_variant(db: &impl HirDatabase, ev: EnumVariant) -> C } pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Cancelable { - let def = def_id.resolve(db)?; + let def = def_id.resolve(db); match def { Def::Module(..) => { log::debug!("trying to get type for module {:?}", def_id); @@ -507,7 +507,7 @@ pub(super) fn type_for_field( def_id: DefId, field: Name, ) -> Cancelable> { - let def = def_id.resolve(db)?; + let def = def_id.resolve(db); let variant_data = match def { Def::Struct(s) => s.variant_data(db)?, Def::EnumVariant(ev) => ev.variant_data(db), @@ -877,7 +877,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } else { return Ok((Ty::Unknown, None)); }; - Ok(match def_id.resolve(self.db)? { + Ok(match def_id.resolve(self.db) { Def::Struct(s) => { let ty = type_for_struct(self.db, s)?; (ty, Some(def_id)) -- cgit v1.2.3