From ae49a22b5cdd47add478fef6bb8ad3d75338e313 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 18 Nov 2019 03:35:46 +0800 Subject: Rebase --- crates/ra_ide_api/src/expand_macro.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/expand_macro.rs b/crates/ra_ide_api/src/expand_macro.rs index 48dc90932..49c096ed5 100644 --- a/crates/ra_ide_api/src/expand_macro.rs +++ b/crates/ra_ide_api/src/expand_macro.rs @@ -1,10 +1,10 @@ //! FIXME: write short doc here use crate::{db::RootDatabase, FilePosition}; +use hir::db::AstDatabase; use ra_db::SourceDatabase; use rustc_hash::FxHashMap; -use hir::db::AstDatabase; use ra_syntax::{ algo::{find_node_at_offset, replace_descendants}, ast::{self}, @@ -47,13 +47,14 @@ fn expand_macro_recur( ) -> Option { let analyzer = hir::SourceAnalyzer::new(db, source, None); let expansion = analyzer.expand(db, ¯o_call)?; - let expanded: SyntaxNode = db.parse_or_expand(expansion.file_id())?; + let new_source = expansion.source(db); + let expanded: SyntaxNode = db.parse_or_expand(new_source.file_id)?; let children = expanded.descendants().filter_map(ast::MacroCall::cast); let mut replaces = FxHashMap::default(); for child in children.into_iter() { - let source = hir::Source::new(expansion.file_id(), source.ast); + let source = new_source.with_ast(source.ast); let new_node = expand_macro_recur(db, source, &child)?; replaces.insert(child.syntax().clone().into(), new_node.into()); -- cgit v1.2.3