aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/lib.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-31 12:37:11 +0100
committerJonas Schievink <[email protected]>2021-06-03 17:09:21 +0100
commite5a2c6596ddd11b0d57042224ac7c1d7691ec33b (patch)
treef0476ad40103b5d3dea60f81fca32c63fe9618d7 /crates/hir/src/lib.rs
parent7f9c4a59d9a84cd8c734286937439b5cd215be27 (diff)
Expand procedural attribute macros
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index d3ef29db4..b43d61d0e 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -534,6 +534,18 @@ impl Module {
534 Some(derive_name.clone()), 534 Some(derive_name.clone()),
535 ) 535 )
536 } 536 }
537 MacroCallKind::Attr { ast_id, invoc_attr_index, attr_name, .. } => {
538 let node = ast_id.to_node(db.upcast());
539 let attr =
540 node.attrs().nth((*invoc_attr_index) as usize).unwrap_or_else(
541 || panic!("cannot find attribute #{}", invoc_attr_index),
542 );
543 (
544 ast_id.file_id,
545 SyntaxNodePtr::from(AstPtr::new(&attr)),
546 Some(attr_name.clone()),
547 )
548 }
537 }; 549 };
538 sink.push(UnresolvedProcMacro { 550 sink.push(UnresolvedProcMacro {
539 file, 551 file,
@@ -558,7 +570,9 @@ impl Module {
558 let node = ast_id.to_node(db.upcast()); 570 let node = ast_id.to_node(db.upcast());
559 (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) 571 (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
560 } 572 }
561 MacroCallKind::Derive { ast_id, .. } => { 573 MacroCallKind::Derive { ast_id, .. }
574 | MacroCallKind::Attr { ast_id, .. } => {
575 // FIXME: point to the attribute instead, this creates very large diagnostics
562 let node = ast_id.to_node(db.upcast()); 576 let node = ast_id.to_node(db.upcast());
563 (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) 577 (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
564 } 578 }