1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // ignore-tidy-linelength
12 // compile-flags: -Z mir-emit-retag -Z mir-opt-level=0 -Z span_free_formats
19 // Make sure we run the pass on a method, not just on bare functions.
20 fn foo<'x>(&self, x: &'x mut i32) -> &'x mut i32 { x }
21 fn foo_shr<'x>(&self, x: &'x i32) -> &'x i32 { x }
27 let v = Test(0).foo(&mut x); // just making sure we do not panic when there is a tuple struct ctor
28 let w = { v }; // assignment
29 let w = w; // reborrow
30 // escape-to-raw (mut)
35 let c: fn(&i32) -> &i32 = |x: &i32| -> &i32 { let _y = x; x };
38 // need to call `foo_shr` or it doesn't even get generated
41 // escape-to-raw (shr)
42 let _w = _w as *const _;
46 // START rustc.{{impl}}-foo.EraseRegions.after.mir
48 // Retag([fn entry] _1);
49 // Retag([fn entry] _2);
56 // END rustc.{{impl}}-foo.EraseRegions.after.mir
57 // START rustc.{{impl}}-foo_shr.EraseRegions.after.mir
59 // Retag([fn entry] _1);
60 // Retag([fn entry] _2);
67 // END rustc.{{impl}}-foo_shr.EraseRegions.after.mir
68 // START rustc.main.EraseRegions.after.mir
73 // _3 = const Test::foo(move _4, move _6) -> bb1;
90 // EscapeToRaw(move _14);
91 // _13 = move _14 as *mut i32 (Misc);
93 // _17 = move _18(move _19) -> bb2;
99 // _21 = const Test::foo_shr(move _22, move _24) -> bb3;
109 // END rustc.main.EraseRegions.after.mir
110 // START rustc.main-{{closure}}.EraseRegions.after.mir
111 // fn main::{{closure}}(_1: &[closure@NodeId(124)], _2: &i32) -> &i32 {
114 // Retag([fn entry] _1);
115 // Retag([fn entry] _2);
125 // END rustc.main-{{closure}}.EraseRegions.after.mir