aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-24 22:56:13 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-24 22:56:13 +0000
commitc42db0bbd750fae19a91f0a0354240ea6c3bafce (patch)
treebeb7030248280fd8c67eb2b2c9cc4b19c6074c17 /crates/ra_hir/src/expr.rs
parentb308375b82a33687f93468d75c7cc628b83a1351 (diff)
parent31d3a56b1865c33ef54e5d76e606965c87676695 (diff)
Merge #623
623: WIP: module id is not def id r=matklad a=matklad This achieves two things: * makes module_tree & item_map per crate, not per source_root * begins the refactoring to remove universal `DefId` in favor of having separate ids for each kind of `Def`. Currently, only modules get a differnt ID though. Co-authored-by: Aleksey Kladov <[email protected]>
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}