1 // Check that CopyPropagation does not propagate an assignment to a function argument
2 // (doing so can break usages of the original argument value)
4 fn dummy(x: u8) -> u8 {
9 // calling `dummy` to make an use of `x` that copyprop cannot eliminate
10 x = dummy(x); // this will assign a local to `x`
19 // self-assignment to a function argument should be eliminated
23 fn arg_src(mut x: i32) -> i32 {
25 x = 123; // Don't propagate this assignment to `y`
30 // Make sure the function actually gets instantiated.
38 // START rustc.foo.CopyPropagation.before.mir
42 // _2 = const dummy(move _3) -> bb1;
49 // END rustc.foo.CopyPropagation.before.mir
50 // START rustc.foo.CopyPropagation.after.mir
54 // _2 = const dummy(move _3) -> bb1;
61 // END rustc.foo.CopyPropagation.after.mir
62 // START rustc.bar.CopyPropagation.before.mir
66 // _2 = const dummy(move _3) -> bb1;
74 // END rustc.bar.CopyPropagation.before.mir
75 // START rustc.bar.CopyPropagation.after.mir
79 // _2 = const dummy(move _3) -> bb1;
87 // END rustc.bar.CopyPropagation.after.mir
88 // START rustc.baz.CopyPropagation.before.mir
97 // END rustc.baz.CopyPropagation.before.mir
98 // START rustc.baz.CopyPropagation.after.mir
106 // END rustc.baz.CopyPropagation.after.mir
107 // START rustc.arg_src.CopyPropagation.before.mir
112 // _1 = const 123i32;
118 // END rustc.arg_src.CopyPropagation.before.mir
119 // START rustc.arg_src.CopyPropagation.after.mir
124 // _1 = const 123i32;
130 // END rustc.arg_src.CopyPropagation.after.mir