Skip to content

Commit 0b2b9a5

Browse files
Merge #5766
5766: Hacky support for fn-like proc macros r=matklad a=jonas-schievink It turns out that this is all that's needed to get something like this working: ```rust #[proc_macro] pub fn function_like_macro(_args: TokenStream) -> TokenStream { TokenStream::from_str("fn fn_success() {}").unwrap() } ``` ```rust function_like_macro!(); fn f() { fn_success(); } ``` The drawback is that it also makes this work, because there is no distinction between different proc macro kinds in the rest of r-a: ```rust #[derive(function_like_macro)] struct S {} fn f() { fn_success(); } ``` Another issue is that it seems to panic, and then panic, when using this on the rustc code base, due to some issue in the inscrutable proc macro bridge code. Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 parents 6deb908 + bee56e6 commit 0b2b9a5

File tree

1 file changed

+3
-3
lines changed
  • crates/proc_macro_api/src

1 file changed

+3
-3
lines changed

crates/proc_macro_api/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ impl ProcMacroClient {
8989
macros
9090
.into_iter()
9191
.filter_map(|(name, kind)| {
92-
// FIXME: Support custom derive only for now.
9392
match kind {
94-
ProcMacroKind::CustomDerive => {
93+
ProcMacroKind::CustomDerive | ProcMacroKind::FuncLike => {
9594
let name = SmolStr::new(&name);
9695
let expander: Arc<dyn tt::TokenExpander> =
9796
Arc::new(ProcMacroProcessExpander {
@@ -101,7 +100,8 @@ impl ProcMacroClient {
101100
});
102101
Some((name, expander))
103102
}
104-
_ => None,
103+
// FIXME: Attribute macro are currently unsupported.
104+
ProcMacroKind::Attr => None,
105105
}
106106
})
107107
.collect()

0 commit comments

Comments
 (0)