From e5a2c6596ddd11b0d57042224ac7c1d7691ec33b Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 31 May 2021 13:37:11 +0200 Subject: Expand procedural attribute macros --- crates/hir/src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/hir/src/lib.rs') 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 { Some(derive_name.clone()), ) } + MacroCallKind::Attr { ast_id, invoc_attr_index, attr_name, .. } => { + let node = ast_id.to_node(db.upcast()); + let attr = + node.attrs().nth((*invoc_attr_index) as usize).unwrap_or_else( + || panic!("cannot find attribute #{}", invoc_attr_index), + ); + ( + ast_id.file_id, + SyntaxNodePtr::from(AstPtr::new(&attr)), + Some(attr_name.clone()), + ) + } }; sink.push(UnresolvedProcMacro { file, @@ -558,7 +570,9 @@ impl Module { let node = ast_id.to_node(db.upcast()); (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) } - MacroCallKind::Derive { ast_id, .. } => { + MacroCallKind::Derive { ast_id, .. } + | MacroCallKind::Attr { ast_id, .. } => { + // FIXME: point to the attribute instead, this creates very large diagnostics let node = ast_id.to_node(db.upcast()); (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) } -- cgit v1.2.3