1 // ignore-wasm32-bare compiled with panic=abort by default
2 // ignore-tidy-linelength
3 // compile-flags: -Z mir-emit-retag -Z mir-opt-level=0 -Z span_free_formats
10 // Make sure we run the pass on a method, not just on bare functions.
11 fn foo<'x>(&self, x: &'x mut i32) -> &'x mut i32 { x }
12 fn foo_shr<'x>(&self, x: &'x i32) -> &'x i32 { x }
22 let v = Test(0).foo(&mut x); // just making sure we do not panic when there is a tuple struct ctor
23 let w = { v }; // assignment
24 let w = w; // reborrow
25 // escape-to-raw (mut)
30 let c: fn(&i32) -> &i32 = |x: &i32| -> &i32 { let _y = x; x };
33 // need to call `foo_shr` or it doesn't even get generated
36 // escape-to-raw (shr)
37 let _w = _w as *const _;
41 // START rustc.{{impl}}-foo.EraseRegions.after.mir
43 // Retag([fn entry] _1);
44 // Retag([fn entry] _2);
51 // END rustc.{{impl}}-foo.EraseRegions.after.mir
52 // START rustc.{{impl}}-foo_shr.EraseRegions.after.mir
54 // Retag([fn entry] _1);
55 // Retag([fn entry] _2);
62 // END rustc.{{impl}}-foo_shr.EraseRegions.after.mir
63 // START rustc.main.EraseRegions.after.mir
68 // _3 = const Test::foo(move _4, move _6) -> [return: bb2, unwind: bb3];
85 // _12 = &raw mut (*_10);
88 // _15 = move _16(move _17) -> bb5;
94 // _19 = const Test::foo_shr(move _20, move _22) -> [return: bb6, unwind: bb7];
99 // END rustc.main.EraseRegions.after.mir
100 // START rustc.main-{{closure}}.EraseRegions.after.mir
101 // fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 {
104 // Retag([fn entry] _1);
105 // Retag([fn entry] _2);
115 // END rustc.main-{{closure}}.EraseRegions.after.mir
116 // START rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
117 // fn std::intrinsics::drop_in_place(_1: *mut Test) -> () {
122 // _3 = const <Test as std::ops::Drop>::drop(move _2) -> bb1;
129 // END rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir