aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-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
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs2
-rw-r--r--crates/ra_ide_api/src/hover.rs2
9 files changed, 16 insertions, 21 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)?;
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index 886dc54d4..cb86ba9a3 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -10,7 +10,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca
10 _ => return Ok(()), 10 _ => return Ok(()),
11 }; 11 };
12 let infer_result = function.infer(ctx.db)?; 12 let infer_result = function.infer(ctx.db)?;
13 let syntax_mapping = function.body_syntax_mapping(ctx.db)?; 13 let syntax_mapping = function.body_syntax_mapping(ctx.db);
14 let expr = match syntax_mapping.node_expr(receiver) { 14 let expr = match syntax_mapping.node_expr(receiver) {
15 Some(expr) => expr, 15 Some(expr) => expr,
16 None => return Ok(()), 16 None => return Ok(()),
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 7229293a4..46fd6883f 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -64,7 +64,7 @@ pub(crate) fn reference_definition(
64 .and_then(ast::MethodCallExpr::cast) 64 .and_then(ast::MethodCallExpr::cast)
65 { 65 {
66 let infer_result = function.infer(db)?; 66 let infer_result = function.infer(db)?;
67 let syntax_mapping = function.body_syntax_mapping(db)?; 67 let syntax_mapping = function.body_syntax_mapping(db);
68 let expr = ast::Expr::cast(method_call.syntax()).unwrap(); 68 let expr = ast::Expr::cast(method_call.syntax()).unwrap();
69 if let Some(def_id) = syntax_mapping 69 if let Some(def_id) = syntax_mapping
70 .node_expr(expr) 70 .node_expr(expr)
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 26f3ced70..0e9c48421 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -74,7 +74,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Cancelable<Option
74 parent_fn 74 parent_fn
75 )); 75 ));
76 let infer = function.infer(db)?; 76 let infer = function.infer(db)?;
77 let syntax_mapping = function.body_syntax_mapping(db)?; 77 let syntax_mapping = function.body_syntax_mapping(db);
78 if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) { 78 if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) {
79 Ok(Some(infer[expr].to_string())) 79 Ok(Some(infer[expr].to_string()))
80 } else if let Some(pat) = ast::Pat::cast(node).and_then(|p| syntax_mapping.node_pat(p)) { 80 } else if let Some(pat) = ast::Pat::cast(node).and_then(|p| syntax_mapping.node_pat(p)) {