From 62ed93db13877888379ea38c843729419bdf99d0 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 8 Nov 2019 09:57:01 +0800 Subject: Refactor and add more comments --- crates/ra_hir_expand/src/db.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir_expand/src') diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index e2860371f..1eaf8bf30 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -148,17 +148,15 @@ pub(crate) fn parse_macro_with_info( let arg_tt = loc.ast_id.to_node(db).token_tree(); let def_tt = loc.def.ast_id.to_node(db).token_tree(); - let arg_start = arg_tt.map(|t| t.syntax().text_range().start()); - let def_start = def_tt.map(|t| t.syntax().text_range().start()); + let arg_range = arg_tt.map(|t| t.syntax().text_range()); + let def_range = def_tt.map(|t| t.syntax().text_range()); let shift = db.macro_def(loc.def)?.0.shift(); - let arg_map = arg_start - .map(|start| exp_map.map_ranges(&expand_info.arg_map, start, shift)) - .unwrap_or_default(); - let def_map = def_start - .map(|start| exp_map.map_ranges(&expand_info.def_map, start, 0)) - .unwrap_or_default(); + let arg_map = + arg_range.map(|it| exp_map.map_ranges(&expand_info.arg_map, it, shift)).unwrap_or_default(); + let def_map = + def_range.map(|it| exp_map.map_ranges(&expand_info.def_map, it, 0)).unwrap_or_default(); let info = ExpansionInfo { arg_map, def_map }; -- cgit v1.2.3