File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1
- // skip-filecheck
2
1
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3
2
// Check that DestinationPropagation does not propagate an assignment to a function argument
4
3
// (doing so can break usages of the original argument value)
@@ -9,25 +8,35 @@ fn dummy(x: u8) -> u8 {
9
8
10
9
// EMIT_MIR copy_propagation_arg.foo.DestinationPropagation.diff
11
10
fn foo ( mut x : u8 ) {
11
+ // CHECK-LABEL: foo
12
+ // CHECK-NOT: {{_.*}} = {{_.*}}
12
13
// calling `dummy` to make a use of `x` that copyprop cannot eliminate
13
14
x = dummy ( x) ; // this will assign a local to `x`
14
15
}
15
16
16
17
// EMIT_MIR copy_propagation_arg.bar.DestinationPropagation.diff
17
18
fn bar ( mut x : u8 ) {
19
+ // CHECK-LABEL: bar
20
+ // CHECK-NOT: {{_.*}} = {{_.*}}
18
21
dummy ( x) ;
19
22
x = 5 ;
20
23
}
21
24
22
25
// EMIT_MIR copy_propagation_arg.baz.DestinationPropagation.diff
23
26
fn baz ( mut x : i32 ) -> i32 {
27
+ // CHECK-LABEL: baz
28
+ // CHECK: {{_.*}} = {{_.*}}
29
+ // CHECK-NOT: {{_.*}} = {{_.*}}
24
30
// self-assignment to a function argument should be eliminated
25
31
x = x;
26
32
x
27
33
}
28
34
29
35
// EMIT_MIR copy_propagation_arg.arg_src.DestinationPropagation.diff
30
36
fn arg_src ( mut x : i32 ) -> i32 {
37
+ // CHECK-LABEL: baz
38
+ // CHECK: {{_.*}} = {{_.*}}
39
+ // CHECK-NOT: {{_.*}} = {{_.*}}
31
40
let y = x;
32
41
x = 123 ; // Don't propagate this assignment to `y`
33
42
y
You can’t perform that action at this time.
0 commit comments