aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/expand_macro.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-01-10 17:26:18 +0000
committerFlorian Diebold <[email protected]>2020-01-11 22:33:04 +0000
commit15fc643e05bf8273e378243edbfb3be7aea7ce11 (patch)
tree9b5bad379840dd25b548158ad962fadd31c54d33 /crates/ra_ide/src/expand_macro.rs
parent12905e5b58f22df026ef30afa6f0bdf7319cbddd (diff)
Fix ordering problem between qualifying paths and substituting params
Diffstat (limited to 'crates/ra_ide/src/expand_macro.rs')
-rw-r--r--crates/ra_ide/src/expand_macro.rs7
1 files changed, 3 insertions, 4 deletions
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;
7 7
8use ra_syntax::{ 8use ra_syntax::{
9 algo::{find_node_at_offset, replace_descendants}, 9 algo::{find_node_at_offset, replace_descendants},
10 ast::{self}, 10 ast, AstNode, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, WalkEvent, T,
11 AstNode, NodeOrToken, SyntaxKind, SyntaxNode, WalkEvent, T,
12}; 11};
13 12
14pub struct ExpandedMacro { 13pub struct ExpandedMacro {
@@ -43,7 +42,7 @@ fn expand_macro_recur(
43 let mut expanded: SyntaxNode = db.parse_or_expand(macro_file_id)?; 42 let mut expanded: SyntaxNode = db.parse_or_expand(macro_file_id)?;
44 43
45 let children = expanded.descendants().filter_map(ast::MacroCall::cast); 44 let children = expanded.descendants().filter_map(ast::MacroCall::cast);
46 let mut replaces = FxHashMap::default(); 45 let mut replaces: FxHashMap<SyntaxElement, SyntaxElement> = FxHashMap::default();
47 46
48 for child in children.into_iter() { 47 for child in children.into_iter() {
49 let node = hir::InFile::new(macro_file_id, &child); 48 let node = hir::InFile::new(macro_file_id, &child);
@@ -59,7 +58,7 @@ fn expand_macro_recur(
59 } 58 }
60 } 59 }
61 60
62 Some(replace_descendants(&expanded, &replaces)) 61 Some(replace_descendants(&expanded, &|n| replaces.get(n).cloned()))
63} 62}
64 63
65// FIXME: It would also be cool to share logic here and in the mbe tests, 64// FIXME: It would also be cool to share logic here and in the mbe tests,