diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index f9b3f5443..692da2895 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -5,14 +5,13 @@ use rustc_hash::FxHashMap; | |||
5 | 5 | ||
6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | SyntaxNodePtr, AstPtr, AstNode,TreeArc, | 8 | SyntaxNodePtr, AstPtr, AstNode, |
9 | ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner} | 9 | ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner} |
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, | 13 | Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, |
14 | name::AsName, | 14 | name::AsName, |
15 | ids::{MacroCallId}, | ||
16 | type_ref::{Mutability, TypeRef}, | 15 | type_ref::{Mutability, TypeRef}, |
17 | }; | 16 | }; |
18 | use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; | 17 | use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; |
@@ -826,8 +825,8 @@ where | |||
826 | .with_file_id(self.current_file_id); | 825 | .with_file_id(self.current_file_id); |
827 | 826 | ||
828 | if let Some(call_id) = self.resolver.resolve_macro_call(self.db, path, ast_id) { | 827 | if let Some(call_id) = self.resolver.resolve_macro_call(self.db, path, ast_id) { |
829 | if let Some(arg) = self.db.macro_arg(call_id) { | 828 | if let Some(tt) = self.db.macro_expand(call_id).ok() { |
830 | if let Some(expr) = expand_macro_to_expr(self.db, call_id, &arg) { | 829 | if let Some(expr) = mbe::token_tree_to_expr(&tt).ok() { |
831 | log::debug!("macro expansion {}", expr.syntax().debug_dump()); | 830 | log::debug!("macro expansion {}", expr.syntax().debug_dump()); |
832 | let old_file_id = | 831 | let old_file_id = |
833 | std::mem::replace(&mut self.current_file_id, call_id.into()); | 832 | std::mem::replace(&mut self.current_file_id, call_id.into()); |
@@ -998,16 +997,6 @@ where | |||
998 | } | 997 | } |
999 | } | 998 | } |
1000 | 999 | ||
1001 | fn expand_macro_to_expr( | ||
1002 | db: &impl HirDatabase, | ||
1003 | macro_call: MacroCallId, | ||
1004 | arg: &tt::Subtree, | ||
1005 | ) -> Option<TreeArc<ast::Expr>> { | ||
1006 | let rules = db.macro_def(macro_call.loc(db).def)?; | ||
1007 | let expanded = rules.expand(&arg).ok()?; | ||
1008 | mbe::token_tree_to_expr(&expanded).ok() | ||
1009 | } | ||
1010 | |||
1011 | pub(crate) fn body_with_source_map_query( | 1000 | pub(crate) fn body_with_source_map_query( |
1012 | db: &impl HirDatabase, | 1001 | db: &impl HirDatabase, |
1013 | def: DefWithBody, | 1002 | def: DefWithBody, |