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
9 // EMIT_MIR retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir
10 // EMIT_MIR retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
12 // Make sure we run the pass on a method, not just on bare functions.
13 fn foo<'x>(&self, x: &'x mut i32) -> &'x mut i32 {
16 fn foo_shr<'x>(&self, x: &'x i32) -> &'x i32 {
21 // EMIT_MIR core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
27 // EMIT_MIR retag.main.SimplifyCfg-elaborate-drops.after.mir
28 // EMIT_MIR retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir
32 let v = Test(0).foo(&mut x); // just making sure we do not panic when there is a tuple struct ctor
33 let w = { v }; // assignment
34 let w = w; // reborrow
35 // escape-to-raw (mut)
40 let c: fn(&i32) -> &i32 = |x: &i32| -> &i32 {
46 // need to call `foo_shr` or it doesn't even get generated
49 // escape-to-raw (shr)
50 let _w = _w as *const _;
55 /// Casting directly to an array should also go through `&raw` and thus add appropriate retags.
56 // EMIT_MIR retag.array_casts.SimplifyCfg-elaborate-drops.after.mir
58 let mut x: [usize; 2] = [0, 0];
59 let p = &mut x as *mut usize;
60 unsafe { *p.add(1) = 1; }
62 let x: [usize; 2] = [0, 1];
63 let p = &x as *const usize;
64 assert_eq!(unsafe { *p.add(1) }, 1);