Skip to content

Instantly share code, notes, and snippets.

@TimNN

TimNN/nodep.mir Secret

Created June 26, 2017 07:30
Show Gist options
  • Save TimNN/b1b678bfb2d3d9af43bff04426966d05 to your computer and use it in GitHub Desktop.
Save TimNN/b1b678bfb2d3d9af43bff04426966d05 to your computer and use it in GitHub Desktop.
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn main() -> () {
let mut _0: (); // return pointer
scope 1 {
let mut _1: Wrapper; // "wrapper" in scope 1 at nodep.rs:16:9: 16:20
}
let mut _2: DropHasLifetime;
let mut _3: &();
let mut _4: &();
let mut _5: DropHasLifetime;
let mut _6: DropHasLifetime;
bb0: {
StorageLive(_1); // scope 0 at nodep.rs:16:9: 16:20
StorageLive(_2); // scope 0 at nodep.rs:16:31: 16:55
StorageLive(_3); // scope 0 at nodep.rs:16:47: 16:54
StorageLive(_4); // scope 0 at nodep.rs:16:47: 16:54
_4 = &(main::STATIC: ()); // scope 0 at nodep.rs:16:47: 16:54
_3 = _4; // scope 0 at nodep.rs:16:47: 16:54
_2 = DropHasLifetime<'_>::{{constructor}}(_3,); // scope 0 at nodep.rs:16:31: 16:55
StorageDead(_3); // scope 0 at nodep.rs:16:55: 16:55
_1 = Wrapper<'_>::{{constructor}}(_2,); // scope 0 at nodep.rs:16:23: 16:56
StorageDead(_2); // scope 0 at nodep.rs:16:56: 16:56
StorageDead(_4); // scope 0 at nodep.rs:16:57: 16:57
StorageLive(_5); // scope 1 at nodep.rs:18:17: 18:43
StorageLive(_6); // scope 1 at nodep.rs:18:33: 18:42
_6 = (_1.0: DropHasLifetime<'_>); // scope 1 at nodep.rs:18:33: 18:42
_5 = const move_and_return(_6) -> bb1; // scope 1 at nodep.rs:18:17: 18:43
}
bb1: {
StorageDead(_6); // scope 1 at nodep.rs:18:43: 18:43
drop((_1.0: DropHasLifetime)) -> bb2; // scope 1 at nodep.rs:18:5: 18:14
}
bb2: {
(_1.0: DropHasLifetime) = _5; // scope 1 at nodep.rs:18:5: 18:14
StorageDead(_5); // scope 1 at nodep.rs:18:43: 18:43
_0 = (); // scope 0 at nodep.rs:13:11: 19:2
drop((_1.0: DropHasLifetime)) -> bb3; // scope 0 at nodep.rs:19:2: 19:2
}
bb3: {
StorageDead(_1); // scope 0 at nodep.rs:19:2: 19:2
return; // scope 0 at nodep.rs:19:2: 19:2
}
}
fn <impl at nodep.rs:3:1: 5:2>::drop(_1: &mut DropHasLifetime) -> () {
let mut _0: (); // return pointer
scope 1 {
let _2: &mut DropHasLifetime; // "self" in scope 1 at nodep.rs:4:13: 4:22
}
bb0: {
StorageLive(_2); // scope 0 at nodep.rs:4:13: 4:22
_2 = _1; // scope 0 at nodep.rs:4:13: 4:22
_0 = (); // scope 1 at nodep.rs:4:24: 4:26
StorageDead(_2); // scope 0 at nodep.rs:4:26: 4:26
return; // scope 1 at nodep.rs:4:26: 4:26
}
}
fn Wrapper(_1: DropHasLifetime) -> Wrapper {
let mut _0: Wrapper; // return pointer
bb0: {
_0 = Wrapper::{{constructor}}(_1,); // scope 0 at nodep.rs:11:1: 11:41
return; // scope 0 at nodep.rs:11:1: 11:41
}
}
static main::STATIC: () = {
let mut _0: (); // return pointer
bb0: {
_0 = (); // scope 0 at nodep.rs:14:25: 14:27
return; // scope 0 at nodep.rs:14:5: 14:28
}
}
fn DropHasLifetime(_1: &()) -> DropHasLifetime {
let mut _0: DropHasLifetime; // return pointer
bb0: {
_0 = DropHasLifetime::{{constructor}}(_1,); // scope 0 at nodep.rs:1:1: 1:40
return; // scope 0 at nodep.rs:1:1: 1:40
}
}
fn move_and_return(_1: T) -> T {
let mut _0: T; // return pointer
scope 1 {
let _2: T; // "val" in scope 1 at nodep.rs:7:23: 7:26
}
let mut _3: T;
bb0: {
StorageLive(_2); // scope 0 at nodep.rs:7:23: 7:26
_2 = _1; // scope 0 at nodep.rs:7:23: 7:26
StorageLive(_3); // scope 1 at nodep.rs:8:5: 8:8
_3 = _2; // scope 1 at nodep.rs:8:5: 8:8
_0 = _3; // scope 1 at nodep.rs:8:5: 8:8
StorageDead(_3); // scope 1 at nodep.rs:8:8: 8:8
StorageDead(_2); // scope 0 at nodep.rs:9:2: 9:2
return; // scope 1 at nodep.rs:9:2: 9:2
}
}
pub struct DropHasLifetime<'a>(&'a ());
impl<'a> ::std::ops::Drop for DropHasLifetime<'a> {
fn drop(&mut self) {}
}
fn move_and_return<T>(val: T) -> T {
val
}
struct Wrapper<'a>(DropHasLifetime<'a>);
fn main() {
static STATIC: () = ();
let mut wrapper = Wrapper(DropHasLifetime(&STATIC));
wrapper.0 = move_and_return(wrapper.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment