aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r--crates/ra_hir/src/expr.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 1a3821692..29469af2c 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -9,7 +9,11 @@ use ra_syntax::{
9 ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor} 9 ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor}
10}; 10};
11 11
12use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName}; 12use crate::{
13 Path, Name, HirDatabase, Function,
14 name::AsName,
15 type_ref::{Mutability, TypeRef},
16};
13use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}; 17use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy};
14 18
15#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 19#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -435,8 +439,8 @@ impl Pat {
435 439
436// Queries 440// Queries
437 441
438pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Arc<Body> { 442pub(crate) fn body_hir(db: &impl HirDatabase, func: Function) -> Arc<Body> {
439 Arc::clone(&body_syntax_mapping(db, def_id).body) 443 Arc::clone(&body_syntax_mapping(db, func).body)
440} 444}
441 445
442struct ExprCollector { 446struct ExprCollector {
@@ -955,14 +959,8 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping {
955 collector.into_body_syntax_mapping(params, body) 959 collector.into_body_syntax_mapping(params, body)
956} 960}
957 961
958pub(crate) fn body_syntax_mapping(db: &impl HirDatabase, def_id: DefId) -> Arc<BodySyntaxMapping> { 962pub(crate) fn body_syntax_mapping(db: &impl HirDatabase, func: Function) -> Arc<BodySyntaxMapping> {
959 let def = def_id.resolve(db); 963 let (_, fn_def) = func.source(db);
960 964 let body_syntax_mapping = collect_fn_body_syntax(&fn_def);
961 let body_syntax_mapping = match def {
962 Def::Function(f) => collect_fn_body_syntax(&f.source(db).1),
963 // TODO: consts, etc.
964 _ => panic!("Trying to get body for item type without body"),
965 };
966
967 Arc::new(body_syntax_mapping) 965 Arc::new(body_syntax_mapping)
968} 966}