]> git.lizzy.rs Git - rust.git/commit
Merge #5766
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Sun, 16 Aug 2020 20:03:06 +0000 (20:03 +0000)
committerGitHub <noreply@github.com>
Sun, 16 Aug 2020 20:03:06 +0000 (20:03 +0000)
commit0b2b9a5508186c16a2e782f47ce7e0e1c5fb8d33
tree67baa61adac64374fc70cf22947212abb83be29f
parent6deb9087bb95352c345470a3e23a9c9f1549bab0
parentbee56e68a3e6b8d70bd8320f6372b95959e377df
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>