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
67 // _2 = const dummy(move _3) -> bb1;
76 // END rustc.bar.CopyPropagation.before.mir
77 // START rustc.bar.CopyPropagation.after.mir
81 // _2 = const dummy(move _3) -> bb1;
89 // END rustc.bar.CopyPropagation.after.mir
90 // START rustc.baz.CopyPropagation.before.mir
99 // END rustc.baz.CopyPropagation.before.mir
100 // START rustc.baz.CopyPropagation.after.mir
108 // END rustc.baz.CopyPropagation.after.mir
109 // START rustc.arg_src.CopyPropagation.before.mir
114 // _1 = const 123i32;
120 // END rustc.arg_src.CopyPropagation.before.mir
121 // START rustc.arg_src.CopyPropagation.after.mir
126 // _1 = const 123i32;
132 // END rustc.arg_src.CopyPropagation.after.mir