Skip to content

Instantly share code, notes, and snippets.

@saethlin
Created January 10, 2023 14:20
Show Gist options
  • Save saethlin/ca1dfa9ed609445e0db30a2023b35099 to your computer and use it in GitHub Desktop.
Save saethlin/ca1dfa9ed609445e0db30a2023b35099 to your computer and use it in GitHub Desktop.
ptr::read MIR for Rust 1.66
fn ptr::read(_1: *const T) -> T {
debug src => _1; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1119:29: 1119:32
let mut _0: T; // return place in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1119:47: 1119:48
let mut _2: mem::maybe_uninit::MaybeUninit<T>; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1127:9: 1127:16
let mut _3: *const T; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:29: 1139:32
let mut _4: *mut T; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:34: 1139:50
let mut _5: &mut mem::maybe_uninit::MaybeUninit<T>; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:34: 1139:50
let mut _6: mem::maybe_uninit::MaybeUninit<T>; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1140:9: 1140:12
let mut _8: *const T; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2222:13: 2222:80
scope 1 {
debug tmp => _2; // in scope 1 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1127:9: 1127:16
scope 2 {
scope 4 (inlined ptr::read::runtime::<T>) { // at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2222:13: 2222:80
debug src => _8; // in scope 4 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2211:39: 2211:41
}
scope 5 (inlined maybe_uninit::MaybeUninit::<T>::as_mut_ptr) { // at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:34: 1139:50
debug self => _5; // in scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:567:29: 567:38
let mut _9: *mut mem::maybe_uninit::MaybeUninit<T>; // in scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:9: 569:23
let mut _10: *mut mem::maybe_uninit::MaybeUninit<T>; // in scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:9: 569:23
}
scope 6 (inlined #[track_caller] maybe_uninit::MaybeUninit::<T>::assume_init) { // at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1140:9: 1140:26
debug self => _6; // in scope 6 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:622:37: 622:41
let _11: (); // in scope 6 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:626:13: 626:48
let mut _12: mem::manually_drop::ManuallyDrop<T>; // in scope 6 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:627:38: 627:48
scope 7 {
scope 8 (inlined ManuallyDrop::<T>::into_inner) { // at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:627:13: 627:49
debug slot => _12; // in scope 8 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/manually_drop.rs:88:29: 88:33
}
}
}
}
}
scope 3 (inlined maybe_uninit::MaybeUninit::<T>::uninit) { // at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1127:19: 1127:45
let mut _7: (); // in scope 3 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:314:31: 314:33
}
bb0: {
StorageLive(_2); // scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1127:9: 1127:16
StorageLive(_7); // scope 3 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:314:31: 314:33
Deinit(_2); // scope 3 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:314:9: 314:35
(_2.0: ()) = move _7; // scope 3 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:314:9: 314:35
StorageDead(_7); // scope 3 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:314:34: 314:35
StorageLive(_3); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:29: 1139:32
_3 = _1; // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:29: 1139:32
StorageLive(_4); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:34: 1139:50
StorageLive(_5); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:34: 1139:50
_5 = &mut _2; // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:34: 1139:50
StorageLive(_9); // scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:9: 569:23
StorageLive(_10); // scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:9: 569:23
_10 = &raw mut (*_5); // scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:9: 569:13
_9 = _10; // scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:9: 569:23
_4 = move _9 as *mut T (PtrToPtr); // scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:9: 569:33
StorageDead(_9); // scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:569:32: 569:33
StorageDead(_10); // scope 5 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:570:5: 570:6
StorageDead(_5); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:49: 1139:50
copy_nonoverlapping(dst = move _4, src = move _3, count = const 1_usize); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:9: 1139:54
StorageDead(_4); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:53: 1139:54
StorageDead(_3); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:53: 1139:54
StorageLive(_6); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1140:9: 1140:12
_6 = move _2; // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1140:9: 1140:12
StorageLive(_11); // scope 7 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:626:13: 626:48
_11 = intrinsics::assert_inhabited::<T>() -> bb1; // scope 7 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:626:13: 626:48
// mir::Constant
// + span: /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:626:13: 626:46
// + literal: Const { ty: extern "rust-intrinsic" fn() {intrinsics::assert_inhabited::<T>}, val: Value(<ZST>) }
}
bb1: {
StorageDead(_11); // scope 7 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:626:48: 626:49
StorageLive(_12); // scope 7 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:627:38: 627:48
_12 = move (_6.1: mem::manually_drop::ManuallyDrop<T>); // scope 7 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:627:38: 627:48
_0 = move (_12.0: T); // scope 8 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/manually_drop.rs:89:9: 89:19
StorageDead(_12); // scope 7 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/maybe_uninit.rs:627:48: 627:49
StorageDead(_6); // scope 2 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1140:25: 1140:26
StorageDead(_2); // scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1142:1: 1142:2
return; // scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1142:2: 1142:2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment