rust/tests/ui/proc-macro/macro-crate-multi-decorator.rs
2023-01-11 09:32:08 +00:00

42 lines
728 B
Rust

// The duplicate macro will create a copy of the item with the given identifier.
// check-pass
// aux-build:duplicate.rs
#[macro_use]
extern crate duplicate;
#[duplicate(MyCopy)]
struct MyStruct {
number: i32,
}
trait TestTrait {
#[duplicate(TestType2)]
type TestType;
#[duplicate(required_fn2)]
fn required_fn(&self);
#[duplicate(provided_fn2)]
fn provided_fn(&self) {}
}
impl TestTrait for MyStruct {
#[duplicate(TestType2)]
type TestType = f64;
#[duplicate(required_fn2)]
fn required_fn(&self) {}
}
fn main() {
let s = MyStruct { number: 42 };
s.required_fn();
s.required_fn2();
s.provided_fn();
s.provided_fn2();
let s = MyCopy { number: 42 };
}