diff options
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 8369c2b40..72c728c93 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -151,10 +151,15 @@ pub(crate) fn parse_macro_with_info( | |||
151 | let arg_start = arg_tt.map(|t| t.syntax().text_range().start()); | 151 | let arg_start = arg_tt.map(|t| t.syntax().text_range().start()); |
152 | let def_start = def_tt.map(|t| t.syntax().text_range().start()); | 152 | let def_start = def_tt.map(|t| t.syntax().text_range().start()); |
153 | 153 | ||
154 | let arg_map = | 154 | let macro_rules = db.macro_def(loc.def).ok_or("Fail to find macro definition").ok()?.0; |
155 | arg_start.map(|start| exp_map.ranges(&expand_info.arg_map, start)).unwrap_or_default(); | 155 | let shift = macro_rules.shift(); |
156 | let def_map = | 156 | |
157 | def_start.map(|start| exp_map.ranges(&expand_info.def_map, start)).unwrap_or_default(); | 157 | let arg_map = arg_start |
158 | .map(|start| exp_map.map_ranges(&expand_info.arg_map, start, shift)) | ||
159 | .unwrap_or_default(); | ||
160 | let def_map = def_start | ||
161 | .map(|start| exp_map.map_ranges(&expand_info.def_map, start, 0)) | ||
162 | .unwrap_or_default(); | ||
158 | 163 | ||
159 | let info = ExpansionInfo { arg_map, def_map }; | 164 | let info = ExpansionInfo { arg_map, def_map }; |
160 | 165 | ||