]>
git.proxmox.com Git - rustc.git/blob - src/test/mir-opt/dest-prop/copy_propagation_arg.rs
1 // Check that DestinationPropagation does not propagate an assignment to a function argument
2 // (doing so can break usages of the original argument value)
3 // compile-flags: -Zunsound-mir-opts
4 fn dummy(x
: u8) -> u8 {
8 // EMIT_MIR copy_propagation_arg.foo.DestinationPropagation.diff
10 // calling `dummy` to make an use of `x` that copyprop cannot eliminate
11 x
= dummy(x
); // this will assign a local to `x`
14 // EMIT_MIR copy_propagation_arg.bar.DestinationPropagation.diff
20 // EMIT_MIR copy_propagation_arg.baz.DestinationPropagation.diff
22 // self-assignment to a function argument should be eliminated
26 // EMIT_MIR copy_propagation_arg.arg_src.DestinationPropagation.diff
27 fn arg_src(mut x
: i32) -> i32 {
29 x
= 123; // Don't propagate this assignment to `y`
34 // Make sure the function actually gets instantiated.