diff options
author | Aleksey Kladov <[email protected]> | 2019-11-14 06:41:46 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-14 06:55:24 +0000 |
commit | e7e85c60d2c225eacc80184a7918ecf6c8ab0563 (patch) | |
tree | d578f2e3e973c4718bdee2c95bc5585fe969a2e8 /crates/ra_hir_def/src/body/lower.rs | |
parent | 8c8ef1432e1891809f48ff691f949047d6527c07 (diff) |
Move original_file to Expander
Diffstat (limited to 'crates/ra_hir_def/src/body/lower.rs')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index cc4bbe11a..602bcb220 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -4,7 +4,7 @@ use hir_expand::{ | |||
4 | either::Either, | 4 | either::Either, |
5 | hygiene::Hygiene, | 5 | hygiene::Hygiene, |
6 | name::{self, AsName, Name}, | 6 | name::{self, AsName, Name}, |
7 | AstId, HirFileId, MacroCallLoc, MacroFileKind, Source, | 7 | AstId, MacroCallLoc, MacroFileKind, Source, |
8 | }; | 8 | }; |
9 | use ra_arena::Arena; | 9 | use ra_arena::Arena; |
10 | use ra_syntax::{ | 10 | use ra_syntax::{ |
@@ -34,12 +34,9 @@ pub(super) fn lower( | |||
34 | params: Option<ast::ParamList>, | 34 | params: Option<ast::ParamList>, |
35 | body: Option<ast::Expr>, | 35 | body: Option<ast::Expr>, |
36 | ) -> (Body, BodySourceMap) { | 36 | ) -> (Body, BodySourceMap) { |
37 | let original_file_id = expander.current_file_id; | ||
38 | |||
39 | ExprCollector { | 37 | ExprCollector { |
40 | expander, | 38 | expander, |
41 | db, | 39 | db, |
42 | original_file_id, | ||
43 | source_map: BodySourceMap::default(), | 40 | source_map: BodySourceMap::default(), |
44 | body: Body { | 41 | body: Body { |
45 | exprs: Arena::default(), | 42 | exprs: Arena::default(), |
@@ -54,7 +51,6 @@ pub(super) fn lower( | |||
54 | struct ExprCollector<DB> { | 51 | struct ExprCollector<DB> { |
55 | db: DB, | 52 | db: DB, |
56 | expander: Expander, | 53 | expander: Expander, |
57 | original_file_id: HirFileId, | ||
58 | 54 | ||
59 | body: Body, | 55 | body: Body, |
60 | source_map: BodySourceMap, | 56 | source_map: BodySourceMap, |
@@ -100,7 +96,7 @@ where | |||
100 | fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId { | 96 | fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId { |
101 | let ptr = Either::A(ptr); | 97 | let ptr = Either::A(ptr); |
102 | let id = self.body.exprs.alloc(expr); | 98 | let id = self.body.exprs.alloc(expr); |
103 | if self.expander.current_file_id == self.original_file_id { | 99 | if !self.expander.is_in_expansion() { |
104 | self.source_map.expr_map.insert(ptr, id); | 100 | self.source_map.expr_map.insert(ptr, id); |
105 | } | 101 | } |
106 | self.source_map | 102 | self.source_map |
@@ -116,7 +112,7 @@ where | |||
116 | fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr<ast::RecordField>) -> ExprId { | 112 | fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr<ast::RecordField>) -> ExprId { |
117 | let ptr = Either::B(ptr); | 113 | let ptr = Either::B(ptr); |
118 | let id = self.body.exprs.alloc(expr); | 114 | let id = self.body.exprs.alloc(expr); |
119 | if self.expander.current_file_id == self.original_file_id { | 115 | if !self.expander.is_in_expansion() { |
120 | self.source_map.expr_map.insert(ptr, id); | 116 | self.source_map.expr_map.insert(ptr, id); |
121 | } | 117 | } |
122 | self.source_map | 118 | self.source_map |
@@ -126,7 +122,7 @@ where | |||
126 | } | 122 | } |
127 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { | 123 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { |
128 | let id = self.body.pats.alloc(pat); | 124 | let id = self.body.pats.alloc(pat); |
129 | if self.expander.current_file_id == self.original_file_id { | 125 | if !self.expander.is_in_expansion() { |
130 | self.source_map.pat_map.insert(ptr, id); | 126 | self.source_map.pat_map.insert(ptr, id); |
131 | } | 127 | } |
132 | self.source_map | 128 | self.source_map |