aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-14 06:43:59 +0000
committerAleksey Kladov <[email protected]>2019-11-14 06:57:57 +0000
commitc89010df2d586eec33b50f3afcc4b2226da32672 (patch)
treeaa2a59b52df1632c3dbedd41ac31f45400f60409 /crates
parente7e85c60d2c225eacc80184a7918ecf6c8ab0563 (diff)
Add Expader::to_source
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_def/src/body.rs4
-rw-r--r--crates/ra_hir_def/src/body/lower.rs14
2 files changed, 8 insertions, 10 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index 1c9c86449..622c836d1 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -34,6 +34,10 @@ impl Expander {
34 self.original_file_id != self.current_file_id 34 self.original_file_id != self.current_file_id
35 } 35 }
36 36
37 fn to_source<T>(&self, ast: T) -> Source<T> {
38 Source { file_id: self.current_file_id, ast }
39 }
40
37 fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> { 41 fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> {
38 self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros() 42 self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros()
39 } 43 }
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 602bcb220..1ea8ce249 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, MacroCallLoc, MacroFileKind, Source, 7 AstId, MacroCallLoc, MacroFileKind,
8}; 8};
9use ra_arena::Arena; 9use ra_arena::Arena;
10use ra_syntax::{ 10use ra_syntax::{
@@ -99,9 +99,7 @@ where
99 if !self.expander.is_in_expansion() { 99 if !self.expander.is_in_expansion() {
100 self.source_map.expr_map.insert(ptr, id); 100 self.source_map.expr_map.insert(ptr, id);
101 } 101 }
102 self.source_map 102 self.source_map.expr_map_back.insert(id, self.expander.to_source(ptr));
103 .expr_map_back
104 .insert(id, Source { file_id: self.expander.current_file_id, ast: ptr });
105 id 103 id
106 } 104 }
107 // desugared exprs don't have ptr, that's wrong and should be fixed 105 // desugared exprs don't have ptr, that's wrong and should be fixed
@@ -115,9 +113,7 @@ where
115 if !self.expander.is_in_expansion() { 113 if !self.expander.is_in_expansion() {
116 self.source_map.expr_map.insert(ptr, id); 114 self.source_map.expr_map.insert(ptr, id);
117 } 115 }
118 self.source_map 116 self.source_map.expr_map_back.insert(id, self.expander.to_source(ptr));
119 .expr_map_back
120 .insert(id, Source { file_id: self.expander.current_file_id, ast: ptr });
121 id 117 id
122 } 118 }
123 fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { 119 fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId {
@@ -125,9 +121,7 @@ where
125 if !self.expander.is_in_expansion() { 121 if !self.expander.is_in_expansion() {
126 self.source_map.pat_map.insert(ptr, id); 122 self.source_map.pat_map.insert(ptr, id);
127 } 123 }
128 self.source_map 124 self.source_map.pat_map_back.insert(id, self.expander.to_source(ptr));
129 .pat_map_back
130 .insert(id, Source { file_id: self.expander.current_file_id, ast: ptr });
131 id 125 id
132 } 126 }
133 127