]> git.lizzy.rs Git - rust.git/blob - src/test/ui/hygiene/fields-move.rs
Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkov
[rust.git] / src / test / ui / hygiene / fields-move.rs
1 // issue #46314
2
3 #![feature(decl_macro)]
4
5 #[derive(Debug)]
6 struct NonCopy(String);
7
8 struct Foo {
9     x: NonCopy,
10 }
11
12 macro copy_modern($foo: ident) {
13    $foo.x
14 }
15
16 macro_rules! copy_legacy {
17     ($foo: ident) => {
18         $foo.x //~ ERROR use of moved value: `foo.x`
19     }
20 }
21
22 fn assert_two_copies(a: NonCopy, b: NonCopy) {
23    println!("Got two copies: {:?}, {:?}", a, b);
24 }
25
26 fn main() {
27     let foo = Foo { x: NonCopy("foo".into()) };
28     assert_two_copies(copy_modern!(foo), foo.x); //~ ERROR use of moved value: `foo.x`
29     assert_two_copies(copy_legacy!(foo), foo.x); //~ ERROR use of moved value: `foo.x`
30 }