aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-15 16:01:59 +0000
committerAleksey Kladov <[email protected]>2019-01-15 16:01:59 +0000
commit040a622c5277511b4835fa35b72c314bf080b8cc (patch)
tree30117173485c6e660b9db7d0fc34c34f724e2b31 /crates/ra_hir
parent7c977a7dcd2bac3b6148f2428bcb586c6354d775 (diff)
remove Cancelable from funciton body
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model_api.rs4
-rw-r--r--crates/ra_hir/src/code_model_impl/function.rs2
-rw-r--r--crates/ra_hir/src/db.rs4
-rw-r--r--crates/ra_hir/src/expr.rs17
-rw-r--r--crates/ra_hir/src/query_definitions.rs2
-rw-r--r--crates/ra_hir/src/ty.rs2
6 files changed, 13 insertions, 18 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index f28e077c6..87175476b 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -301,13 +301,13 @@ impl Function {
301 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) -> Arc<BodySyntaxMapping> {
305 db.body_syntax_mapping(self.def_id) 305 db.body_syntax_mapping(self.def_id)
306 } 306 }
307 307
308 pub fn scopes(&self, db: &impl HirDatabase) -> Cancelable<ScopesWithSyntaxMapping> { 308 pub fn scopes(&self, db: &impl HirDatabase) -> Cancelable<ScopesWithSyntaxMapping> {
309 let scopes = db.fn_scopes(self.def_id)?; 309 let scopes = db.fn_scopes(self.def_id)?;
310 let syntax_mapping = db.body_syntax_mapping(self.def_id)?; 310 let syntax_mapping = db.body_syntax_mapping(self.def_id);
311 Ok(ScopesWithSyntaxMapping { 311 Ok(ScopesWithSyntaxMapping {
312 scopes, 312 scopes,
313 syntax_mapping, 313 syntax_mapping,
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs
index 8d6b7fc19..d34803e32 100644
--- a/crates/ra_hir/src/code_model_impl/function.rs
+++ b/crates/ra_hir/src/code_model_impl/function.rs
@@ -20,7 +20,7 @@ impl Function {
20 Function { def_id } 20 Function { def_id }
21 } 21 }
22 22
23 pub(crate) fn body(&self, db: &impl HirDatabase) -> Cancelable<Arc<Body>> { 23 pub(crate) fn body(&self, db: &impl HirDatabase) -> Arc<Body> {
24 db.body_hir(self.def_id) 24 db.body_hir(self.def_id)
25 } 25 }
26 26
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index 6229f9778..c81b8f5f4 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -107,12 +107,12 @@ pub trait HirDatabase: SyntaxDatabase
107 use fn crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query; 107 use fn crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query;
108 } 108 }
109 109
110 fn body_hir(def_id: DefId) -> Cancelable<Arc<crate::expr::Body>> { 110 fn body_hir(def_id: DefId) -> Arc<crate::expr::Body> {
111 type BodyHirQuery; 111 type BodyHirQuery;
112 use fn crate::expr::body_hir; 112 use fn crate::expr::body_hir;
113 } 113 }
114 114
115 fn body_syntax_mapping(def_id: DefId) -> Cancelable<Arc<crate::expr::BodySyntaxMapping>> { 115 fn body_syntax_mapping(def_id: DefId) -> Arc<crate::expr::BodySyntaxMapping> {
116 type BodySyntaxMappingQuery; 116 type BodySyntaxMappingQuery;
117 use fn crate::expr::body_syntax_mapping; 117 use fn crate::expr::body_syntax_mapping;
118 } 118 }
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index a1e8da348..4e8dc0c54 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -4,10 +4,8 @@ use std::sync::Arc;
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
5 5
6use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; 6use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
7use ra_db::{LocalSyntaxPtr, Cancelable}; 7use ra_db::LocalSyntaxPtr;
8use ra_syntax::{ 8use ra_syntax::ast::{self, AstNode, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor};
9 ast::{self, AstNode, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor}
10};
11 9
12use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName}; 10use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName};
13use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}; 11use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy};
@@ -358,8 +356,8 @@ impl Pat {
358 356
359// Queries 357// Queries
360 358
361pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<Body>> { 359pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Arc<Body> {
362 Ok(Arc::clone(&body_syntax_mapping(db, def_id)?.body)) 360 Arc::clone(&body_syntax_mapping(db, def_id).body)
363} 361}
364 362
365struct ExprCollector { 363struct ExprCollector {
@@ -828,10 +826,7 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping {
828 collector.into_body_syntax_mapping(params, body) 826 collector.into_body_syntax_mapping(params, body)
829} 827}
830 828
831pub(crate) fn body_syntax_mapping( 829pub(crate) fn body_syntax_mapping(db: &impl HirDatabase, def_id: DefId) -> Arc<BodySyntaxMapping> {
832 db: &impl HirDatabase,
833 def_id: DefId,
834) -> Cancelable<Arc<BodySyntaxMapping>> {
835 let def = def_id.resolve(db); 830 let def = def_id.resolve(db);
836 831
837 let body_syntax_mapping = match def { 832 let body_syntax_mapping = match def {
@@ -840,5 +835,5 @@ pub(crate) fn body_syntax_mapping(
840 _ => panic!("Trying to get body for item type without body"), 835 _ => panic!("Trying to get body for item type without body"),
841 }; 836 };
842 837
843 Ok(Arc::new(body_syntax_mapping)) 838 Arc::new(body_syntax_mapping)
844} 839}
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs
index 7ff942f6a..31086d1e1 100644
--- a/crates/ra_hir/src/query_definitions.rs
+++ b/crates/ra_hir/src/query_definitions.rs
@@ -19,7 +19,7 @@ use crate::{
19}; 19};
20 20
21pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<FnScopes>> { 21pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<FnScopes>> {
22 let body = db.body_hir(def_id)?; 22 let body = db.body_hir(def_id);
23 let res = FnScopes::new(body); 23 let res = FnScopes::new(body);
24 Ok(Arc::new(res)) 24 Ok(Arc::new(res))
25} 25}
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 3607969ed..519660084 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -1205,7 +1205,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1205pub fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceResult>> { 1205pub fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceResult>> {
1206 db.check_canceled(); 1206 db.check_canceled();
1207 let function = Function::new(def_id); // TODO: consts also need inference 1207 let function = Function::new(def_id); // TODO: consts also need inference
1208 let body = function.body(db)?; 1208 let body = function.body(db);
1209 let scopes = db.fn_scopes(def_id)?; 1209 let scopes = db.fn_scopes(def_id)?;
1210 let module = function.module(db)?; 1210 let module = function.module(db)?;
1211 let impl_block = function.impl_block(db)?; 1211 let impl_block = function.impl_block(db)?;