mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 09:48:10 +00:00
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>
This commit is contained in:
commit
0b2b9a5508
1 changed files with 3 additions and 3 deletions
|
@ -89,9 +89,8 @@ impl ProcMacroClient {
|
|||
macros
|
||||
.into_iter()
|
||||
.filter_map(|(name, kind)| {
|
||||
// FIXME: Support custom derive only for now.
|
||||
match kind {
|
||||
ProcMacroKind::CustomDerive => {
|
||||
ProcMacroKind::CustomDerive | ProcMacroKind::FuncLike => {
|
||||
let name = SmolStr::new(&name);
|
||||
let expander: Arc<dyn tt::TokenExpander> =
|
||||
Arc::new(ProcMacroProcessExpander {
|
||||
|
@ -101,7 +100,8 @@ impl ProcMacroClient {
|
|||
});
|
||||
Some((name, expander))
|
||||
}
|
||||
_ => None,
|
||||
// FIXME: Attribute macro are currently unsupported.
|
||||
ProcMacroKind::Attr => None,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
|
Loading…
Reference in a new issue