mashup
mashup copied to clipboard
Mashup macro cannot be invoked more than once in the same scope
#[macro_use]
extern crate mashup;
mashup! {
sub1["y"] = Y y;
}
mashup! {
sub2["z"] = Z z;
}
sub1! {
struct "y";
}
sub2! {
struct "z";
}
fn main() {}
error[E0428]: the name `ProcMacroHack` is defined multiple times
--> src/main.rs:4:1
|
4 | / mashup! {
5 | | sub1["y"] = Y y;
6 | | }
| |_^ `ProcMacroHack` redefined here
7 |
8 | / mashup! {
9 | | sub2["z"] = Z z;
10 | | }
| |_- previous definition of the type `ProcMacroHack` here
|
= note: `ProcMacroHack` must be defined only once in the type namespace of this module
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
This limitation can be lifted once function-like procedural macros in item context are stabilized.
@dtolnay If I still wanna do this for fields like:
mashup! {
get["get" $field] = get_ $field;
}
mashup! {
set["set" $field] = set_ $field;
}
Is there any hack for that?
You shouldn't need separate substitution macros for that.
mashup! {
m["get" $field] = get_ $field;
m["set" $field] = set_ $field;
}