File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Regression test for #46314
12
+
13
+ #![ feature( nll) ]
14
+ #![ feature( decl_macro) ]
15
+
16
+ struct NonCopy ( String ) ;
17
+
18
+ struct Wrapper {
19
+ inner : NonCopy ,
20
+ }
21
+
22
+ macro inner_copy( $wrapper: ident) {
23
+ $wrapper. inner
24
+ }
25
+
26
+ fn main ( ) {
27
+ let wrapper = Wrapper {
28
+ inner : NonCopy ( "foo" . into ( ) ) ,
29
+ } ;
30
+ assert_two_non_copy (
31
+ inner_copy ! ( wrapper) ,
32
+ wrapper. inner ,
33
+ //~^ ERROR use of moved value: `wrapper.inner` [E0382]
34
+ ) ;
35
+ }
36
+
37
+ fn assert_two_non_copy ( a : NonCopy , b : NonCopy ) {
38
+ assert_eq ! ( a. 0 , b. 0 ) ;
39
+ }
Original file line number Diff line number Diff line change
1
+ error[E0382]: use of moved value: `wrapper.inner`
2
+ --> $DIR/decl-macro-illegal-copy.rs:32:9
3
+ |
4
+ LL | $wrapper.inner
5
+ | -------------- value moved here
6
+ ...
7
+ LL | wrapper.inner,
8
+ | ^^^^^^^^^^^^^ value used here after move
9
+ |
10
+ = note: move occurs because `wrapper.inner` has type `NonCopy`, which does not implement the `Copy` trait
11
+
12
+ error: aborting due to previous error
13
+
14
+ For more information about this error, try `rustc --explain E0382`.
You can’t perform that action at this time.
0 commit comments