2018-07-27 17:27:20 +00:00
|
|
|
#![feature(no_core, unboxed_closures)]
|
2018-06-17 16:05:11 +00:00
|
|
|
#![no_core]
|
2018-07-18 11:43:17 +00:00
|
|
|
#![allow(dead_code)]
|
2018-06-17 16:05:11 +00:00
|
|
|
|
2018-07-24 12:10:53 +00:00
|
|
|
extern crate mini_core;
|
2018-06-17 16:05:11 +00:00
|
|
|
|
2018-07-24 12:10:53 +00:00
|
|
|
use mini_core::*;
|
2018-07-20 12:20:37 +00:00
|
|
|
|
2018-06-27 13:23:40 +00:00
|
|
|
fn abc(a: u8) -> u8 {
|
2018-06-17 16:05:11 +00:00
|
|
|
a * 2
|
|
|
|
}
|
|
|
|
|
2018-06-27 13:23:40 +00:00
|
|
|
fn bcd(b: bool, a: u8) -> u8 {
|
2018-06-17 16:05:11 +00:00
|
|
|
if b {
|
|
|
|
a * 2
|
|
|
|
} else {
|
|
|
|
a * 3
|
|
|
|
}
|
2018-06-20 13:15:28 +00:00
|
|
|
}
|
2018-06-17 17:10:00 +00:00
|
|
|
|
2018-06-23 16:26:54 +00:00
|
|
|
// FIXME make calls work
|
2018-07-18 11:43:17 +00:00
|
|
|
fn call() {
|
2018-06-17 17:10:00 +00:00
|
|
|
abc(42);
|
|
|
|
}
|
2018-06-18 16:39:07 +00:00
|
|
|
|
|
|
|
fn indirect_call() {
|
|
|
|
let f: fn() = call;
|
|
|
|
f();
|
2018-07-18 11:43:17 +00:00
|
|
|
}
|
2018-06-23 16:26:54 +00:00
|
|
|
|
|
|
|
enum BoolOption {
|
|
|
|
Some(bool),
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn option_unwrap_or(o: BoolOption, d: bool) -> bool {
|
|
|
|
match o {
|
|
|
|
BoolOption::Some(b) => b,
|
|
|
|
BoolOption::None => d,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-27 13:23:40 +00:00
|
|
|
fn ret_42() -> u8 {
|
2018-06-23 16:26:54 +00:00
|
|
|
42
|
2018-06-18 16:39:07 +00:00
|
|
|
}
|
2018-07-14 14:39:49 +00:00
|
|
|
|
|
|
|
fn return_str() -> &'static str {
|
|
|
|
"hello world"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn promoted_val() -> &'static u8 {
|
|
|
|
&(1 * 2)
|
|
|
|
}
|
2018-07-18 12:21:13 +00:00
|
|
|
|
|
|
|
fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 {
|
|
|
|
abc as *const u8
|
|
|
|
}
|
2018-07-18 13:17:22 +00:00
|
|
|
|
|
|
|
fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool {
|
|
|
|
a == b
|
|
|
|
}
|
2018-07-18 14:22:29 +00:00
|
|
|
|
2018-07-20 11:38:49 +00:00
|
|
|
fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) {
|
2018-07-18 14:22:29 +00:00
|
|
|
(
|
2018-07-31 10:25:16 +00:00
|
|
|
a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8,
|
|
|
|
b as u32,
|
2018-07-18 14:22:29 +00:00
|
|
|
)
|
|
|
|
}
|
2018-07-18 15:07:10 +00:00
|
|
|
|
2018-07-19 17:37:34 +00:00
|
|
|
fn char_cast(c: char) -> u8 {
|
|
|
|
c as u8
|
|
|
|
}
|
|
|
|
|
2018-07-18 15:07:10 +00:00
|
|
|
struct DebugTuple(());
|
|
|
|
|
|
|
|
fn debug_tuple() -> DebugTuple {
|
|
|
|
DebugTuple(())
|
|
|
|
}
|
2018-07-20 12:20:37 +00:00
|
|
|
|
2018-07-21 16:38:08 +00:00
|
|
|
fn size_of<T>() -> usize {
|
2018-07-31 10:25:16 +00:00
|
|
|
unsafe { intrinsics::size_of::<T>() }
|
2018-07-21 16:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn use_size_of() -> usize {
|
|
|
|
size_of::<u64>()
|
2018-07-20 12:20:37 +00:00
|
|
|
}
|
|
|
|
|
2018-07-21 16:38:08 +00:00
|
|
|
/*unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) {
|
|
|
|
intrinsics::copy::<u8>(src, dst, 1);
|
|
|
|
}*/
|
|
|
|
|
2018-07-20 12:20:37 +00:00
|
|
|
/*unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) {
|
|
|
|
let copy2 = ©::<u8>;
|
|
|
|
copy2(src, dst, 1);
|
|
|
|
}*/
|
2018-07-21 16:44:34 +00:00
|
|
|
|
|
|
|
const Abc: u8 = 6 * 7;
|
|
|
|
|
|
|
|
fn use_const() -> u8 {
|
|
|
|
Abc
|
|
|
|
}
|
2018-07-20 11:38:49 +00:00
|
|
|
|
2018-07-27 17:01:38 +00:00
|
|
|
fn call_closure_3arg() {
|
2018-07-31 10:25:16 +00:00
|
|
|
(|_, _, _| {})(0u8, 42u16, 0u8)
|
2018-07-27 17:01:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn call_closure_2arg() {
|
2018-07-31 10:25:16 +00:00
|
|
|
(|_, _| {})(0u8, 42u16)
|
2018-07-20 11:38:49 +00:00
|
|
|
}
|
2018-07-26 08:48:50 +00:00
|
|
|
|
2018-07-27 17:27:20 +00:00
|
|
|
struct IsNotEmpty;
|
|
|
|
|
2018-07-31 10:25:16 +00:00
|
|
|
impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty {
|
2018-07-27 17:27:20 +00:00
|
|
|
type Output = bool;
|
|
|
|
|
|
|
|
#[inline]
|
2018-07-31 10:25:16 +00:00
|
|
|
extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> bool {
|
2018-07-27 17:27:20 +00:00
|
|
|
self.call_mut(arg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-31 10:25:16 +00:00
|
|
|
impl<'a, 'b> FnMut<(&'a &'b [u16],)> for IsNotEmpty {
|
2018-07-27 17:27:20 +00:00
|
|
|
#[inline]
|
2018-07-31 10:25:16 +00:00
|
|
|
extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16],)) -> bool {
|
2018-07-27 17:27:20 +00:00
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-26 08:48:50 +00:00
|
|
|
fn eq_char(a: char, b: char) -> bool {
|
|
|
|
a == b
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn transmute(c: char) -> u32 {
|
|
|
|
intrinsics::transmute(c)
|
|
|
|
}
|
2018-07-29 15:22:40 +00:00
|
|
|
|
|
|
|
unsafe fn call_uninit() -> u8 {
|
|
|
|
intrinsics::uninit()
|
|
|
|
}
|