Debian Codegraph @

gcc/testsuite/rust/borrowck/test_move.rs

raw
1 // { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" }
2 // { dg-enable-nn-line-numbers "" }
3
4 fn test_move() {
5 struct A {
6 i: i32,
7 }
8 let a = A { i: 1 };
9 let b = a;
10 let c = a; //~ ERROR
11 // { dg-error "use of moved value" "" { target *-*-* } .-1 }
12 /*
13 { dg-begin-multiline-output "" }
14 NN | let b = a;
15 | ~
16 | |
17 | value moved here
18 NN | let c = a; //~ ERROR
19 | ^
20 | |
21 | moved value used here
22 { dg-end-multiline-output "" }
23 */
24
25 }
26
27 fn test_move_fixed() {
28
29 let a = 1; // a is now primitive and can be copied
30 let b = a;
31 let c = a;
32 }