blob: b4b5ac6aa3b1e1a9759afd261f62815a448e3d45 (
plain)
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
41
42
43
|
#![feature(custom_mir, core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*;
// EMIT_MIR as_cast.int_to_int.built.after.mir
#[custom_mir(dialect = "built")]
fn int_to_int(x: u32) -> i32 {
mir!(
{
RET = x as i32;
Return()
}
)
}
// EMIT_MIR as_cast.float_to_int.built.after.mir
#[custom_mir(dialect = "built")]
fn float_to_int(x: f32) -> i32 {
mir!(
{
RET = x as i32;
Return()
}
)
}
// EMIT_MIR as_cast.int_to_ptr.built.after.mir
#[custom_mir(dialect = "built")]
fn int_to_ptr(x: usize) -> *const i32 {
mir!(
{
RET = x as *const i32;
Return()
}
)
}
fn main() {
assert_eq!(int_to_int(5), 5);
assert_eq!(float_to_int(5.), 5);
assert_eq!(int_to_ptr(0), std::ptr::null());
}
|