aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr/lower.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-03 11:38:47 +0100
committerGitHub <[email protected]>2019-09-03 11:38:47 +0100
commit1c0672b7f802c7e7814ba9a1b3b21ecf866343d6 (patch)
treedf19e2603745c348e2e5d8289be80c2f511b0b0d /crates/ra_hir/src/expr/lower.rs
parentf5b60a53f68100937d561acae51e06b5ebb6bd18 (diff)
parent9c3b25177e3c8d609dd24d2c2e01cbb82cab665f (diff)
Merge #1756
1756: Correctly build BodySourceMap for macro-expanded expressions r=flodiebold a=matklad r? @flodiebold Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/expr/lower.rs')
-rw-r--r--crates/ra_hir/src/expr/lower.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs
index 7b3e55b7e..6afd80989 100644
--- a/crates/ra_hir/src/expr/lower.rs
+++ b/crates/ra_hir/src/expr/lower.rs
@@ -14,7 +14,7 @@ use crate::{
14 ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, 14 ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy},
15 type_ref::TypeRef, 15 type_ref::TypeRef,
16 DefWithBody, Either, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, 16 DefWithBody, Either, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path,
17 Resolver, 17 Resolver, Source,
18}; 18};
19 19
20use super::{ 20use super::{
@@ -103,11 +103,13 @@ where
103 let id = self.body.exprs.alloc(expr); 103 let id = self.body.exprs.alloc(expr);
104 if self.current_file_id == self.original_file_id { 104 if self.current_file_id == self.original_file_id {
105 self.source_map.expr_map.insert(ptr, id); 105 self.source_map.expr_map.insert(ptr, id);
106 self.source_map.expr_map_back.insert(id, ptr);
107 } 106 }
107 self.source_map
108 .expr_map_back
109 .insert(id, Source { file_id: self.current_file_id, ast: ptr });
108 id 110 id
109 } 111 }
110 // deshugared exprs don't have ptr, that's wrong and should be fixed 112 // desugared exprs don't have ptr, that's wrong and should be fixed
111 // somehow. 113 // somehow.
112 fn alloc_expr_desugared(&mut self, expr: Expr) -> ExprId { 114 fn alloc_expr_desugared(&mut self, expr: Expr) -> ExprId {
113 self.body.exprs.alloc(expr) 115 self.body.exprs.alloc(expr)
@@ -117,18 +119,18 @@ where
117 let id = self.body.exprs.alloc(expr); 119 let id = self.body.exprs.alloc(expr);
118 if self.current_file_id == self.original_file_id { 120 if self.current_file_id == self.original_file_id {
119 self.source_map.expr_map.insert(ptr, id); 121 self.source_map.expr_map.insert(ptr, id);
120 self.source_map.expr_map_back.insert(id, ptr);
121 } 122 }
123 self.source_map
124 .expr_map_back
125 .insert(id, Source { file_id: self.current_file_id, ast: ptr });
122 id 126 id
123 } 127 }
124 fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { 128 fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId {
125 let id = self.body.pats.alloc(pat); 129 let id = self.body.pats.alloc(pat);
126
127 if self.current_file_id == self.original_file_id { 130 if self.current_file_id == self.original_file_id {
128 self.source_map.pat_map.insert(ptr, id); 131 self.source_map.pat_map.insert(ptr, id);
129 self.source_map.pat_map_back.insert(id, ptr);
130 } 132 }
131 133 self.source_map.pat_map_back.insert(id, Source { file_id: self.current_file_id, ast: ptr });
132 id 134 id
133 } 135 }
134 136