-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for emitting validation statements
- Loading branch information
Showing
4 changed files
with
121 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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. | ||
|
||
// compile-flags: -Z verbose -Z mir-emit-validate | ||
|
||
fn foo(_x: &mut i32) {} | ||
|
||
fn main() { | ||
let mut x = 0; | ||
foo(&mut x); | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.node4.EraseRegions.after.mir | ||
// fn foo(_1: &ReErased mut i32) -> () { | ||
// bb0: { | ||
// Validate(Acquire, [_1@&ReFree(DefId { krate: CrateNum(0), node: DefIndex(3) => validate_1/8cd878b::foo[0] }, BrAnon(0)) mut i32]); | ||
// return; | ||
// } | ||
// } | ||
// END rustc.node4.EraseRegions.after.mir | ||
// START rustc.node11.EraseRegions.after.mir | ||
// fn main() -> () { | ||
// bb0: { | ||
// Validate(Suspend(ReScope(Misc(NodeId(20)))), [_1@i32]); | ||
// _4 = &ReErased mut _1; | ||
// Validate(Acquire, [(*_4)@i32/ReScope(Misc(NodeId(20)))]); | ||
// Validate(Suspend(ReScope(Misc(NodeId(20)))), [(*_4)@i32/ReScope(Misc(NodeId(20)))]); | ||
// _3 = &ReErased mut (*_4); | ||
// Validate(Acquire, [(*_3)@i32/ReScope(Misc(NodeId(20)))]); | ||
// Validate(Release, [_3@&ReScope(Misc(NodeId(20))) mut i32]); | ||
// _2 = const foo(_3) -> bb1; | ||
// } | ||
// | ||
// bb1: { | ||
// Validate(Acquire, [_2@()]); | ||
// EndRegion(ReScope(Misc(NodeId(20)))); | ||
// return; | ||
// } | ||
// } | ||
// END rustc.node11.EraseRegions.after.mir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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. | ||
|
||
// compile-flags: -Z verbose -Z mir-emit-validate | ||
|
||
fn main() { | ||
let _x : Box<[i32]> = Box::new([1, 2, 3]); | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.node4.EraseRegions.after.mir | ||
// fn main() -> () { | ||
// bb1: { | ||
// Validate(Release, [_2@std::boxed::Box<[i32; 3]>]); | ||
// _1 = _2 as std::boxed::Box<[i32]> (Unsize); | ||
// Validate(Acquire, [_1@std::boxed::Box<[i32]>]); | ||
// } | ||
// } | ||
// END rustc.node4.EraseRegions.after.mir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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. | ||
|
||
// compile-flags: -Z verbose -Z mir-emit-validate | ||
|
||
struct Test { | ||
x: i32 | ||
} | ||
|
||
fn foo(_x: &i32) {} | ||
|
||
fn main() { | ||
let t = Test { x: 0 }; | ||
let t = &t; | ||
foo(&t.x); | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.node16.EraseRegions.after.mir | ||
// fn main() -> () { | ||
// let mut _5: &ReErased i32; | ||
// bb0: { | ||
// Validate(Suspend(ReScope(Misc(NodeId(31)))), [((*_2).0: i32)@i32/ReScope(Remainder(BlockRemainder { block: NodeId(18), first_statement_index: 1 })) (imm)]); | ||
// _5 = &ReErased ((*_2).0: i32); | ||
// Validate(Acquire, [(*_5)@i32/ReScope(Misc(NodeId(31))) (imm)]); | ||
// Validate(Suspend(ReScope(Misc(NodeId(31)))), [(*_5)@i32/ReScope(Misc(NodeId(31))) (imm)]); | ||
// _4 = &ReErased (*_5); | ||
// Validate(Acquire, [(*_4)@i32/ReScope(Misc(NodeId(31))) (imm)]); | ||
// Validate(Release, [_4@&ReScope(Misc(NodeId(31))) i32]); | ||
// _3 = const foo(_4) -> bb1; | ||
// } | ||
// bb1: { | ||
// EndRegion(ReScope(Misc(NodeId(31)))); | ||
// EndRegion(ReScope(Remainder(BlockRemainder { block: NodeId(18), first_statement_index: 1 }))); | ||
// return; | ||
// } | ||
// } | ||
// END rustc.node16.EraseRegions.after.mir |