1 // unit-test: LowerIntrinsics
2 // ignore-wasm32 compiled with panic=abort by default
4 #![feature(core_intrinsics)]
7 // EMIT_MIR lower_intrinsics.wrapping.LowerIntrinsics.diff
8 pub fn wrapping(a: i32, b: i32) {
9 let _x = core::intrinsics::wrapping_add(a, b);
10 let _y = core::intrinsics::wrapping_sub(a, b);
11 let _z = core::intrinsics::wrapping_mul(a, b);
14 // EMIT_MIR lower_intrinsics.size_of.LowerIntrinsics.diff
15 pub fn size_of<T>() -> usize {
16 core::intrinsics::size_of::<T>()
19 // EMIT_MIR lower_intrinsics.align_of.LowerIntrinsics.diff
20 pub fn align_of<T>() -> usize {
21 core::intrinsics::min_align_of::<T>()
24 // EMIT_MIR lower_intrinsics.forget.LowerIntrinsics.diff
25 pub fn forget<T>(t: T) {
26 core::intrinsics::forget(t)
29 // EMIT_MIR lower_intrinsics.unreachable.LowerIntrinsics.diff
30 pub fn unreachable() -> ! {
31 unsafe { core::intrinsics::unreachable() };
34 // EMIT_MIR lower_intrinsics.non_const.LowerIntrinsics.diff
35 pub fn non_const<T>() -> usize {
36 // Check that lowering works with non-const operand as a func.
37 let size_of_t = core::intrinsics::size_of::<T>;
47 // EMIT_MIR lower_intrinsics.discriminant.LowerIntrinsics.diff
48 pub fn discriminant<T>(t: T) {
49 core::intrinsics::discriminant_value(&t);
50 core::intrinsics::discriminant_value(&0);
51 core::intrinsics::discriminant_value(&());
52 core::intrinsics::discriminant_value(&E::B);