aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/lib.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index c9b14d0c8..a3d617e1f 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -47,8 +47,8 @@ mod marks;
47use std::hash::Hash; 47use std::hash::Hash;
48 48
49use hir_expand::{ 49use hir_expand::{
50 ast_id_map::FileAstId, db::AstDatabase, hygiene::Hygiene, AstId, HirFileId, InFile, 50 ast_id_map::FileAstId, db::AstDatabase, eager::expand_eager_macro, hygiene::Hygiene, AstId,
51 MacroCallId, MacroCallKind, MacroDefId, 51 HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
52}; 52};
53use ra_arena::{impl_arena_id, RawId}; 53use ra_arena::{impl_arena_id, RawId};
54use ra_db::{impl_intern_key, salsa, CrateId}; 54use ra_db::{impl_intern_key, salsa, CrateId};
@@ -459,8 +459,21 @@ impl AsMacroCall for AstIdWithPath<ast::MacroCall> {
459 db: &impl AstDatabase, 459 db: &impl AstDatabase,
460 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, 460 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>,
461 ) -> Option<MacroCallId> { 461 ) -> Option<MacroCallId> {
462 let def = resolver(self.path.clone())?; 462 let def: MacroDefId = resolver(self.path.clone())?;
463 Some(def.as_call_id(db, MacroCallKind::FnLike(self.ast_id))) 463
464 if let MacroDefKind::BuiltInEager(_) = def.kind {
465 let macro_call = InFile::new(self.ast_id.file_id, self.ast_id.to_node(db));
466 let hygiene = Hygiene::new(db, self.ast_id.file_id);
467
468 Some(
469 expand_eager_macro(db, macro_call, def, &|path: ast::Path| {
470 resolver(path::ModPath::from_src(path, &hygiene)?)
471 })?
472 .into(),
473 )
474 } else {
475 Some(def.as_lazy_macro(db, MacroCallKind::FnLike(self.ast_id)).into())
476 }
464 } 477 }
465} 478}
466 479
@@ -471,6 +484,6 @@ impl AsMacroCall for AstIdWithPath<ast::ModuleItem> {
471 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, 484 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>,
472 ) -> Option<MacroCallId> { 485 ) -> Option<MacroCallId> {
473 let def = resolver(self.path.clone())?; 486 let def = resolver(self.path.clone())?;
474 Some(def.as_call_id(db, MacroCallKind::Attr(self.ast_id))) 487 Some(def.as_lazy_macro(db, MacroCallKind::Attr(self.ast_id)).into())
475 } 488 }
476} 489}