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 // compile-flags: -Z identify_regions -Z span_free_formats -Z emit-end-regions
13 // Unwinding should EndRegion for in-scope borrows: Borrowing via by-ref closure.
17 foo(|| -> i32 { d.0 });
21 impl Drop for D { fn drop(&mut self) { println!("dropping D({})", self.0); } }
23 fn foo<F>(f: F) where F: FnOnce() -> i32 {
24 if f() > 0 { panic!("im positive"); }
28 // START rustc.main.SimplifyCfg-qualify-consts.after.mir
36 // let mut _3: [closure@NodeId(18) d:&'14s D];
37 // let mut _4: &'14s D;
40 // _1 = D::{{constructor}}(const 0i32,);
44 // _3 = [closure@NodeId(18)] { d: move _4 };
46 // _2 = const foo(move _3) -> [return: bb2, unwind: bb3];
55 // drop(_1) -> [return: bb4, unwind: bb1];
66 // END rustc.main.SimplifyCfg-qualify-consts.after.mir
68 // START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir
69 // fn main::{{closure}}(_1: [closure@NodeId(18) d:&'14s D]) -> i32 {
73 // _0 = ((*(_1.0: &'14s D)).0: i32);
76 // END rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir