diff options
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/scope.rs | 12 |
2 files changed, 11 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index d8e911aa5..331736cb2 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr` |
2 | //! representation. | ||
2 | 3 | ||
3 | use hir_expand::{ | 4 | use hir_expand::{ |
4 | either::Either, | 5 | either::Either, |
@@ -17,7 +18,7 @@ use test_utils::tested_by; | |||
17 | use crate::{ | 18 | use crate::{ |
18 | body::{Body, BodySourceMap, Expander, PatPtr}, | 19 | body::{Body, BodySourceMap, Expander, PatPtr}, |
19 | builtin_type::{BuiltinFloat, BuiltinInt}, | 20 | builtin_type::{BuiltinFloat, BuiltinInt}, |
20 | db::DefDatabase2, | 21 | db::DefDatabase, |
21 | expr::{ | 22 | expr::{ |
22 | ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, | 23 | ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, |
23 | MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, | 24 | MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, |
@@ -28,7 +29,7 @@ use crate::{ | |||
28 | }; | 29 | }; |
29 | 30 | ||
30 | pub(super) fn lower( | 31 | pub(super) fn lower( |
31 | db: &impl DefDatabase2, | 32 | db: &impl DefDatabase, |
32 | expander: Expander, | 33 | expander: Expander, |
33 | params: Option<ast::ParamList>, | 34 | params: Option<ast::ParamList>, |
34 | body: Option<ast::Expr>, | 35 | body: Option<ast::Expr>, |
@@ -57,7 +58,7 @@ struct ExprCollector<DB> { | |||
57 | 58 | ||
58 | impl<'a, DB> ExprCollector<&'a DB> | 59 | impl<'a, DB> ExprCollector<&'a DB> |
59 | where | 60 | where |
60 | DB: DefDatabase2, | 61 | DB: DefDatabase, |
61 | { | 62 | { |
62 | fn collect( | 63 | fn collect( |
63 | mut self, | 64 | mut self, |
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 58740b679..625aa39dd 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Name resolution for expressions. |
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use hir_expand::name::Name; | 4 | use hir_expand::name::Name; |
@@ -7,7 +7,7 @@ use rustc_hash::FxHashMap; | |||
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | body::Body, | 9 | body::Body, |
10 | db::DefDatabase2, | 10 | db::DefDatabase, |
11 | expr::{Expr, ExprId, Pat, PatId, Statement}, | 11 | expr::{Expr, ExprId, Pat, PatId, Statement}, |
12 | DefWithBodyId, | 12 | DefWithBodyId, |
13 | }; | 13 | }; |
@@ -45,7 +45,7 @@ pub struct ScopeData { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | impl ExprScopes { | 47 | impl ExprScopes { |
48 | pub(crate) fn expr_scopes_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<ExprScopes> { | 48 | pub(crate) fn expr_scopes_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> { |
49 | let body = db.body(def); | 49 | let body = db.body(def); |
50 | Arc::new(ExprScopes::new(&*body)) | 50 | Arc::new(ExprScopes::new(&*body)) |
51 | } | 51 | } |
@@ -54,8 +54,8 @@ impl ExprScopes { | |||
54 | let mut scopes = | 54 | let mut scopes = |
55 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; | 55 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; |
56 | let root = scopes.root_scope(); | 56 | let root = scopes.root_scope(); |
57 | scopes.add_params_bindings(body, root, body.params()); | 57 | scopes.add_params_bindings(body, root, &body.params); |
58 | compute_expr_scopes(body.body_expr(), body, &mut scopes, root); | 58 | compute_expr_scopes(body.body_expr, body, &mut scopes, root); |
59 | scopes | 59 | scopes |
60 | } | 60 | } |
61 | 61 | ||
@@ -176,7 +176,7 @@ mod tests { | |||
176 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; | 176 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; |
177 | use test_utils::{assert_eq_text, covers, extract_offset}; | 177 | use test_utils::{assert_eq_text, covers, extract_offset}; |
178 | 178 | ||
179 | use crate::{db::DefDatabase2, test_db::TestDB, FunctionId, ModuleDefId}; | 179 | use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId}; |
180 | 180 | ||
181 | fn find_function(db: &TestDB, file_id: FileId) -> FunctionId { | 181 | fn find_function(db: &TestDB, file_id: FileId) -> FunctionId { |
182 | let krate = db.test_crate(); | 182 | let krate = db.test_crate(); |