diff options
author | Aleksey Kladov <[email protected]> | 2019-01-15 15:50:16 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-15 15:50:16 +0000 |
commit | f1367e0370d5de5cba13c853c7df5f0c5a0edf59 (patch) | |
tree | 6ea2db9840f91aa39b65680ace9d3079a140a12c /crates/ra_hir | |
parent | 9dd4099d9388b5f61e99f923dd6c523f76ad43ff (diff) |
remove Cancelable from navigation target
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 6 |
5 files changed, 11 insertions, 12 deletions
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 { | |||
297 | self.def_id | 297 | self.def_id |
298 | } | 298 | } |
299 | 299 | ||
300 | pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::FnDef>)> { | 300 | pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::FnDef>) { |
301 | Ok(def_id_to_ast(db, self.def_id)) | 301 | def_id_to_ast(db, self.def_id) |
302 | } | 302 | } |
303 | 303 | ||
304 | pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Cancelable<Arc<BodySyntaxMapping>> { | 304 | pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Cancelable<Arc<BodySyntaxMapping>> { |
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 { | |||
148 | } else { | 148 | } else { |
149 | return Ok(PerNs::none()); | 149 | return Ok(PerNs::none()); |
150 | }; | 150 | }; |
151 | let module = match curr.resolve(db)? { | 151 | let module = match curr.resolve(db) { |
152 | Def::Module(it) => it, | 152 | Def::Module(it) => it, |
153 | Def::Enum(e) => { | 153 | Def::Enum(e) => { |
154 | if segments.len() == idx + 1 { | 154 | 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( | |||
832 | db: &impl HirDatabase, | 832 | db: &impl HirDatabase, |
833 | def_id: DefId, | 833 | def_id: DefId, |
834 | ) -> Cancelable<Arc<BodySyntaxMapping>> { | 834 | ) -> Cancelable<Arc<BodySyntaxMapping>> { |
835 | let def = def_id.resolve(db)?; | 835 | let def = def_id.resolve(db); |
836 | 836 | ||
837 | let body_syntax_mapping = match def { | 837 | let body_syntax_mapping = match def { |
838 | Def::Function(f) => collect_fn_body_syntax(&f.source(db)?.1), | 838 | Def::Function(f) => collect_fn_body_syntax(&f.source(db).1), |
839 | // TODO: consts, etc. | 839 | // TODO: consts, etc. |
840 | _ => panic!("Trying to get body for item type without body"), | 840 | _ => panic!("Trying to get body for item type without body"), |
841 | }; | 841 | }; |
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 { | |||
159 | db.as_ref().id2loc(self) | 159 | db.as_ref().id2loc(self) |
160 | } | 160 | } |
161 | 161 | ||
162 | pub fn resolve(self, db: &impl HirDatabase) -> Cancelable<Def> { | 162 | pub fn resolve(self, db: &impl HirDatabase) -> Def { |
163 | let loc = self.loc(db); | 163 | let loc = self.loc(db); |
164 | let res = match loc.kind { | 164 | match loc.kind { |
165 | DefKind::Module => { | 165 | DefKind::Module => { |
166 | let module = Module::from_module_id(db, loc.source_root_id, loc.module_id); | 166 | let module = Module::from_module_id(db, loc.source_root_id, loc.module_id); |
167 | Def::Module(module) | 167 | Def::Module(module) |
@@ -195,8 +195,7 @@ impl DefId { | |||
195 | 195 | ||
196 | DefKind::StructCtor => Def::Item, | 196 | DefKind::StructCtor => Def::Item, |
197 | DefKind::Item => Def::Item, | 197 | DefKind::Item => Def::Item, |
198 | }; | 198 | } |
199 | Ok(res) | ||
200 | } | 199 | } |
201 | 200 | ||
202 | pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreeArc<SyntaxNode>) { | 201 | pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreeArc<SyntaxNode>) { |
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 | |||
481 | } | 481 | } |
482 | 482 | ||
483 | pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Ty> { | 483 | pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Ty> { |
484 | let def = def_id.resolve(db)?; | 484 | let def = def_id.resolve(db); |
485 | match def { | 485 | match def { |
486 | Def::Module(..) => { | 486 | Def::Module(..) => { |
487 | log::debug!("trying to get type for module {:?}", def_id); | 487 | log::debug!("trying to get type for module {:?}", def_id); |
@@ -507,7 +507,7 @@ pub(super) fn type_for_field( | |||
507 | def_id: DefId, | 507 | def_id: DefId, |
508 | field: Name, | 508 | field: Name, |
509 | ) -> Cancelable<Option<Ty>> { | 509 | ) -> Cancelable<Option<Ty>> { |
510 | let def = def_id.resolve(db)?; | 510 | let def = def_id.resolve(db); |
511 | let variant_data = match def { | 511 | let variant_data = match def { |
512 | Def::Struct(s) => s.variant_data(db)?, | 512 | Def::Struct(s) => s.variant_data(db)?, |
513 | Def::EnumVariant(ev) => ev.variant_data(db), | 513 | Def::EnumVariant(ev) => ev.variant_data(db), |
@@ -877,7 +877,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
877 | } else { | 877 | } else { |
878 | return Ok((Ty::Unknown, None)); | 878 | return Ok((Ty::Unknown, None)); |
879 | }; | 879 | }; |
880 | Ok(match def_id.resolve(self.db)? { | 880 | Ok(match def_id.resolve(self.db) { |
881 | Def::Struct(s) => { | 881 | Def::Struct(s) => { |
882 | let ty = type_for_struct(self.db, s)?; | 882 | let ty = type_for_struct(self.db, s)?; |
883 | (ty, Some(def_id)) | 883 | (ty, Some(def_id)) |