2 // ignore-wasm32-bare compiled with panic=abort by default
3 // ignore-tidy-linelength
4 // compile-flags: -Z mir-emit-retag -Z mir-opt-level=0 -Z span_free_formats
10 // EMIT_MIR retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir
11 // EMIT_MIR retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
13 // Make sure we run the pass on a method, not just on bare functions.
14 fn foo<'x>(&self, x: &'x mut i32) -> &'x mut i32 {
17 fn foo_shr<'x>(&self, x: &'x i32) -> &'x i32 {
22 // EMIT_MIR core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
28 // EMIT_MIR retag.main.SimplifyCfg-elaborate-drops.after.mir
29 // EMIT_MIR retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir
33 let v = Test(0).foo(&mut x); // just making sure we do not panic when there is a tuple struct ctor
34 let w = { v }; // assignment
35 let w = w; // reborrow
36 // escape-to-raw (mut)
41 let c: fn(&i32) -> &i32 = |x: &i32| -> &i32 {
47 // need to call `foo_shr` or it doesn't even get generated
50 // escape-to-raw (shr)
51 let _w = _w as *const _;
56 /// Casting directly to an array should also go through `&raw` and thus add appropriate retags.
57 // EMIT_MIR retag.array_casts.SimplifyCfg-elaborate-drops.after.mir
59 let mut x: [usize; 2] = [0, 0];
60 let p = &mut x as *mut usize;
61 unsafe { *p.add(1) = 1; }
63 let x: [usize; 2] = [0, 1];
64 let p = &x as *const usize;
65 assert_eq!(unsafe { *p.add(1) }, 1);