rust/tests/ui/nll/decl-macro-illegal-copy.rs

29 lines
491 B
Rust
Raw Normal View History

2018-04-04 03:36:38 -05:00
// Regression test for #46314
#![feature(decl_macro)]
struct NonCopy(String);
struct Wrapper {
inner: NonCopy,
}
macro inner_copy($wrapper:ident) {
$wrapper.inner
}
fn main() {
let wrapper = Wrapper {
inner: NonCopy("foo".into()),
};
assert_two_non_copy(
inner_copy!(wrapper),
wrapper.inner,
//~^ ERROR use of moved value: `wrapper.inner` [E0382]
);
}
fn assert_two_non_copy(a: NonCopy, b: NonCopy) {
assert_eq!(a.0, b.0);
}