Created
December 9, 2016 15:01
-
-
Save bluss/8845ff0fd80be92100327ef89c2db963 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #![crate_type="lib"] | |
| #[no_mangle] | |
| pub fn id_option(a: Option<u32>) -> Option<u32> { | |
| match a { | |
| Some(x) => Some(x), | |
| None => None, | |
| } | |
| } | |
| #[no_mangle] | |
| pub fn id_result(a: Result<u32, i32>) -> Result<u32, i32> { | |
| match a { | |
| Ok(x) => Ok(x), | |
| Err(y) => Err(y), | |
| } | |
| } | |
| /* | |
| fn id_option(_1: std::option::Option<u32>) -> std::option::Option<u32> { | |
| let mut _0: std::option::Option<u32>; // return pointer | |
| scope 1 { | |
| let _2: std::option::Option<u32>; // "a" in scope 1 at id.rs:4:18: 4:19 | |
| scope 2 { | |
| let _3: u32; // "x" in scope 2 at id.rs:6:14: 6:15 | |
| } | |
| } | |
| let mut _4: u32; | |
| bb0: { | |
| StorageLive(_2); // scope 0 at id.rs:4:18: 4:19 | |
| _2 = _1; // scope 0 at id.rs:4:18: 4:19 | |
| switch(_2) -> [None: bb1, Some: bb2]; // scope 1 at id.rs:6:9: 6:16 | |
| } | |
| bb1: { | |
| _0 = std::option::Option<u32>::None; // scope 1 at id.rs:7:17: 7:21 | |
| goto -> bb3; // scope 1 at id.rs:5:5: 8:6 | |
| } | |
| bb2: { | |
| StorageLive(_3); // scope 1 at id.rs:6:14: 6:15 | |
| _3 = ((_2 as Some).0: u32); // scope 1 at id.rs:6:14: 6:15 | |
| StorageLive(_4); // scope 2 at id.rs:6:25: 6:26 | |
| _4 = _3; // scope 2 at id.rs:6:25: 6:26 | |
| _0 = std::option::Option<u32>::Some(_4,); // scope 2 at id.rs:6:20: 6:27 | |
| StorageDead(_4); // scope 2 at id.rs:6:27: 6:27 | |
| goto -> bb3; // scope 1 at id.rs:5:5: 8:6 | |
| } | |
| bb3: { | |
| StorageDead(_3); // scope 1 at id.rs:8:6: 8:6 | |
| StorageDead(_2); // scope 0 at id.rs:9:2: 9:2 | |
| return; // scope 1 at id.rs:9:2: 9:2 | |
| } | |
| } | |
| */ |
This file contains hidden or 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
| // MIR for `id_result` | |
| // node_id = 22 | |
| // pass_name = Deaggregator | |
| // disambiguator = before | |
| fn id_result(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { | |
| let mut _0: std::result::Result<u32, i32>; // return pointer | |
| scope 1 { | |
| let _2: std::result::Result<u32, i32>; // "a" in scope 1 at id.rs:12:18: 12:19 | |
| scope 2 { | |
| let _3: u32; // "x" in scope 2 at id.rs:14:12: 14:13 | |
| } | |
| scope 3 { | |
| let _4: i32; // "y" in scope 3 at id.rs:15:13: 15:14 | |
| } | |
| } | |
| let mut _5: u32; | |
| let mut _6: i32; | |
| bb0: { | |
| StorageLive(_2); // scope 0 at id.rs:12:18: 12:19 | |
| _2 = _1; // scope 0 at id.rs:12:18: 12:19 | |
| switch(_2) -> [Ok: bb1, Err: bb2]; // scope 1 at id.rs:14:9: 14:14 | |
| } | |
| bb1: { | |
| StorageLive(_3); // scope 1 at id.rs:14:12: 14:13 | |
| _3 = ((_2 as Ok).0: u32); // scope 1 at id.rs:14:12: 14:13 | |
| StorageLive(_5); // scope 2 at id.rs:14:21: 14:22 | |
| _5 = _3; // scope 2 at id.rs:14:21: 14:22 | |
| _0 = std::result::Result<u32, i32>::Ok(_5,); // scope 2 at id.rs:14:18: 14:23 | |
| StorageDead(_5); // scope 2 at id.rs:14:23: 14:23 | |
| goto -> bb3; // scope 1 at id.rs:13:5: 16:6 | |
| } | |
| bb2: { | |
| StorageLive(_4); // scope 1 at id.rs:15:13: 15:14 | |
| _4 = ((_2 as Err).0: i32); // scope 1 at id.rs:15:13: 15:14 | |
| StorageLive(_6); // scope 3 at id.rs:15:23: 15:24 | |
| _6 = _4; // scope 3 at id.rs:15:23: 15:24 | |
| _0 = std::result::Result<u32, i32>::Err(_6,); // scope 3 at id.rs:15:19: 15:25 | |
| StorageDead(_6); // scope 3 at id.rs:15:25: 15:25 | |
| goto -> bb3; // scope 1 at id.rs:13:5: 16:6 | |
| } | |
| bb3: { | |
| StorageDead(_4); // scope 1 at id.rs:16:6: 16:6 | |
| StorageDead(_3); // scope 1 at id.rs:16:6: 16:6 | |
| StorageDead(_2); // scope 0 at id.rs:17:2: 17:2 | |
| return; // scope 1 at id.rs:17:2: 17:2 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment