1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
// skip-filecheck
#![feature(custom_mir, core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*;
// EMIT_MIR simple_assign.simple.built.after.mir
#[custom_mir(dialect = "built")]
pub fn simple(x: i32) -> i32 {
mir!(
let temp1: i32;
let temp2: _;
{
StorageLive(temp1);
temp1 = x;
Goto(exit)
}
exit = {
temp2 = Move(temp1);
StorageDead(temp1);
RET = temp2;
Return()
}
)
}
// EMIT_MIR simple_assign.simple_ref.built.after.mir
#[custom_mir(dialect = "built")]
pub fn simple_ref(x: &mut i32) -> &mut i32 {
mir!({
RET = Move(x);
Return()
})
}
fn main() {
assert_eq!(5, simple(5));
}
|