Closed
Description
Implementing traits doesn't seem to work either in declarative macros. This code looks like it should compile:
#![feature(decl_macro)]
pub macro create_struct($a:ident) {
struct $a;
impl Clone for $a {
fn clone(&self) -> Self {
$a
}
}
}
fn main() {
create_struct!(Test);
Test.clone();
}
But it does this instead:
Compiling playground v0.0.1 (file:///playground)
error[E0046]: not all trait items implemented, missing: `clone`
--> src/main.rs:5:5
|
5 | / impl Clone for $a {
6 | | fn clone(&self) -> Self {
7 | | $a
8 | | }
9 | | }
| |_____^ missing `clone` in implementation
...
13 | create_struct!(Test);
| --------------------- in this macro invocation
|
= note: `clone` from trait: `fn(&Self) -> Self`
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.