rust/tests/mir-opt/building/custom/simple_assign.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
762 B
Rust
Raw Normal View History

// skip-filecheck
2022-08-03 06:30:13 -05:00
#![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: _;
{
2023-01-18 18:00:00 -06:00
StorageLive(temp1);
2022-08-03 06:30:13 -05:00
temp1 = x;
Goto(exit)
}
exit = {
temp2 = Move(temp1);
2023-01-18 18:00:00 -06:00
StorageDead(temp1);
2022-08-03 06:30:13 -05:00
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));
}