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 {
14 fn foo_shr<'x>(&self, x: &'x i32) -> &'x i32 {
26 let v = Test(0).foo(&mut x); // just making sure we do not panic when there is a tuple struct ctor
27 let w = { v }; // assignment
28 let w = w; // reborrow
29 // escape-to-raw (mut)
34 let c: fn(&i32) -> &i32 = |x: &i32| -> &i32 {
40 // need to call `foo_shr` or it doesn't even get generated
43 // escape-to-raw (shr)
44 let _w = _w as *const _;
48 // START rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir
50 // Retag([fn entry] _1);
51 // Retag([fn entry] _2);
58 // END rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir
59 // START rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
61 // Retag([fn entry] _1);
62 // Retag([fn entry] _2);
69 // END rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
70 // START rustc.main.SimplifyCfg-elaborate-drops.after.mir
75 // _3 = const Test::foo(move _4, move _6) -> [return: bb2, unwind: bb3];
92 // _12 = &raw mut (*_10);
95 // _15 = move _16(move _17) -> bb5;
101 // _19 = const Test::foo_shr(move _20, move _22) -> [return: bb6, unwind: bb7];
106 // END rustc.main.SimplifyCfg-elaborate-drops.after.mir
107 // START rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir
108 // fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 {
111 // Retag([fn entry] _1);
112 // Retag([fn entry] _2);
122 // END rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir
123 // START rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
124 // fn std::intrinsics::drop_in_place(_1: *mut Test) -> () {
129 // _3 = const <Test as std::ops::Drop>::drop(move _2) -> bb1;
136 // END rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir