blob: 94882bca5a77a266fc97b42c6d78cf625323d5ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" }
// { dg-enable-nn-line-numbers "" }
fn test_move_conditional(b1: bool, b2:bool) {
struct A {
i: i32,
}
let a = A { i: 1 };
let b = a;
if b1 {
let b = a;
// { dg-error "use of moved value" "" { target *-*-* } .-1 }
/*
{ dg-begin-multiline-output "" }
NN | let b = a;
| ~
| |
| value moved here
NN | if b1 {
NN | let b = a;
| ~
| |
| value moved here
......
NN | let c = a;
| ^
| |
| moved value used here
{ dg-end-multiline-output "" }
*/
}
if b2 {
let c = a;
// { dg-error "use of moved value" "" { target *-*-* } .-1 }
/*
{ dg-begin-multiline-output "" }
NN | let b = a;
| ~
| |
| value moved here
NN | if b1 {
NN | let b = a;
| ^
| |
| moved value used here
......
NN | let c = a;
| ~
| |
| value moved here
{ dg-end-multiline-output "" }
*/
}
}
fn test_move_fixed(b1: bool, b2:bool) {
let a = 1; // a is now primitive and can be copied
let b = a;
if b1 {
let b = a;
}
if b2 {
let c = a;
}
}
|