2017-07-28 15:16:17 -07:00
|
|
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2017-07-28 15:42:11 -07:00
|
|
|
// ignore-tidy-linelength
|
2017-07-31 15:46:36 -07:00
|
|
|
// compile-flags: -Z verbose -Z mir-emit-validate=1
|
2017-07-28 15:16:17 -07:00
|
|
|
|
2017-07-31 18:33:45 -07:00
|
|
|
struct Test;
|
|
|
|
|
|
|
|
impl Test {
|
|
|
|
// Make sure we run the pass on a method, not just on bare functions.
|
|
|
|
fn foo(&self, _x: &mut i32) {}
|
|
|
|
}
|
2017-07-28 15:16:17 -07:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = 0;
|
2017-07-31 18:33:45 -07:00
|
|
|
Test.foo(&mut x);
|
2017-07-31 19:51:10 -07:00
|
|
|
|
|
|
|
// Also test closures
|
|
|
|
let c = |x: &mut i32| { let y = &*x; *y };
|
|
|
|
c(&mut x);
|
2017-07-28 15:16:17 -07:00
|
|
|
}
|
|
|
|
|
2017-07-31 19:51:10 -07:00
|
|
|
// FIXME: Also test code generated inside the closure, make sure it has validation. Unfortunately,
|
|
|
|
// the interesting lines of code also contain name of the source file, so we cannot test for it.
|
|
|
|
|
2017-07-28 15:16:17 -07:00
|
|
|
// END RUST SOURCE
|
2017-07-31 18:33:45 -07:00
|
|
|
// START rustc.node10.EraseRegions.after.mir
|
2017-07-28 15:16:17 -07:00
|
|
|
// bb0: {
|
2017-07-31 18:33:45 -07:00
|
|
|
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]);
|
2017-07-28 15:16:17 -07:00
|
|
|
// return;
|
|
|
|
// }
|
2017-07-31 18:33:45 -07:00
|
|
|
// END rustc.node10.EraseRegions.after.mir
|
|
|
|
// START rustc.node21.EraseRegions.after.mir
|
2017-07-28 15:16:17 -07:00
|
|
|
// fn main() -> () {
|
|
|
|
// bb0: {
|
2017-07-31 18:33:45 -07:00
|
|
|
// Validate(Suspend(ReScope(Misc(NodeId(30)))), [_1: i32]);
|
|
|
|
// _6 = &ReErased mut _1;
|
|
|
|
// Validate(Acquire, [(*_6): i32/ReScope(Misc(NodeId(30)))]);
|
|
|
|
// Validate(Suspend(ReScope(Misc(NodeId(30)))), [(*_6): i32/ReScope(Misc(NodeId(30)))]);
|
|
|
|
// _5 = &ReErased mut (*_6);
|
|
|
|
// Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(30)))]);
|
|
|
|
// Validate(Release, [_3: &ReScope(Misc(NodeId(30))) Test, _5: &ReScope(Misc(NodeId(30))) mut i32]);
|
|
|
|
// _2 = const Test::foo(_3, _5) -> bb1;
|
2017-07-28 15:16:17 -07:00
|
|
|
// }
|
|
|
|
//
|
|
|
|
// bb1: {
|
2017-07-31 15:59:29 -07:00
|
|
|
// Validate(Acquire, [_2: ()]);
|
2017-07-31 18:33:45 -07:00
|
|
|
// EndRegion(ReScope(Misc(NodeId(30))));
|
2017-07-28 15:16:17 -07:00
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// }
|
2017-07-31 18:33:45 -07:00
|
|
|
// END rustc.node21.EraseRegions.after.mir
|