From 15fc643e05bf8273e378243edbfb3be7aea7ce11 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 10 Jan 2020 18:26:18 +0100 Subject: Fix ordering problem between qualifying paths and substituting params --- crates/ra_ide/src/expand_macro.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide/src/expand_macro.rs') diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index bdbc31704..0f7b6e875 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs @@ -7,8 +7,7 @@ use rustc_hash::FxHashMap; use ra_syntax::{ algo::{find_node_at_offset, replace_descendants}, - ast::{self}, - AstNode, NodeOrToken, SyntaxKind, SyntaxNode, WalkEvent, T, + ast, AstNode, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, WalkEvent, T, }; pub struct ExpandedMacro { @@ -43,7 +42,7 @@ fn expand_macro_recur( let mut expanded: SyntaxNode = db.parse_or_expand(macro_file_id)?; let children = expanded.descendants().filter_map(ast::MacroCall::cast); - let mut replaces = FxHashMap::default(); + let mut replaces: FxHashMap = FxHashMap::default(); for child in children.into_iter() { let node = hir::InFile::new(macro_file_id, &child); @@ -59,7 +58,7 @@ fn expand_macro_recur( } } - Some(replace_descendants(&expanded, &replaces)) + Some(replace_descendants(&expanded, &|n| replaces.get(n).cloned())) } // FIXME: It would also be cool to share logic here and in the mbe tests, -- cgit v1.2.3