Is it possible to generate custom MIR(hand-writing MIR from std::intrinsics::mir
) based on the MIR provided below?
// 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 place in scope 0 at 000.rs:9:11: 9:11
bb0: {
_0 = const (); // scope 0 at 000.rs:9:11: 11:2
return; // scope 0 at 000.rs:11:2: 11:2
}
}
const BAR_OFFSET: usize = {
let mut _0: usize; // return place in scope 0 at 000.rs:10:23: 10:28
bb0: {
_0 = OffsetOf(Foo<'_>, [0]); // scope 0 at /rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs:1322:5: 1322:50
return; // scope 0 at 000.rs:10:5: 10:61
}
}
The original Rust code is as follows:
#![feature(offset_of)]
extern crate core;
use core::mem::offset_of;
struct Foo<'a> {
bar: &'a (),
}
fn main() {
const BAR_OFFSET: usize = offset_of!(Foo<'static>, bar);
}