• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![feature(no_core, unboxed_closures)]
2 #![no_core]
3 #![allow(dead_code)]
4 
5 extern crate mini_core;
6 
7 use mini_core::*;
8 
abc(a: u8) -> u89 pub fn abc(a: u8) -> u8 {
10     a * 2
11 }
12 
bcd(b: bool, a: u8) -> u813 pub fn bcd(b: bool, a: u8) -> u8 {
14     if b { a * 2 } else { a * 3 }
15 }
16 
call()17 pub fn call() {
18     abc(42);
19 }
20 
indirect_call()21 pub fn indirect_call() {
22     let f: fn() = call;
23     f();
24 }
25 
26 pub enum BoolOption {
27     Some(bool),
28     None,
29 }
30 
option_unwrap_or(o: BoolOption, d: bool) -> bool31 pub fn option_unwrap_or(o: BoolOption, d: bool) -> bool {
32     match o {
33         BoolOption::Some(b) => b,
34         BoolOption::None => d,
35     }
36 }
37 
ret_42() -> u838 pub fn ret_42() -> u8 {
39     42
40 }
41 
return_str() -> &'static str42 pub fn return_str() -> &'static str {
43     "hello world"
44 }
45 
promoted_val() -> &'static u846 pub fn promoted_val() -> &'static u8 {
47     &(1 * 2)
48 }
49 
cast_ref_to_raw_ptr(abc: &u8) -> *const u850 pub fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 {
51     abc as *const u8
52 }
53 
cmp_raw_ptr(a: *const u8, b: *const u8) -> bool54 pub fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool {
55     a == b
56 }
57 
int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32)58 pub fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) {
59     (
60         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,
61         b as u32,
62     )
63 }
64 
char_cast(c: char) -> u865 pub fn char_cast(c: char) -> u8 {
66     c as u8
67 }
68 
69 pub struct DebugTuple(());
70 
debug_tuple() -> DebugTuple71 pub fn debug_tuple() -> DebugTuple {
72     DebugTuple(())
73 }
74 
size_of<T>() -> usize75 pub fn size_of<T>() -> usize {
76     intrinsics::size_of::<T>()
77 }
78 
use_size_of() -> usize79 pub fn use_size_of() -> usize {
80     size_of::<u64>()
81 }
82 
use_copy_intrinsic(src: *const u8, dst: *mut u8)83 pub unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) {
84     intrinsics::copy::<u8>(src, dst, 1);
85 }
86 
use_copy_intrinsic_ref(src: *const u8, dst: *mut u8)87 pub unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) {
88     let copy2 = &intrinsics::copy::<u8>;
89     copy2(src, dst, 1);
90 }
91 
92 pub const ABC: u8 = 6 * 7;
93 
use_const() -> u894 pub fn use_const() -> u8 {
95     ABC
96 }
97 
call_closure_3arg()98 pub fn call_closure_3arg() {
99     (|_, _, _| {})(0u8, 42u16, 0u8)
100 }
101 
call_closure_2arg()102 pub fn call_closure_2arg() {
103     (|_, _| {})(0u8, 42u16)
104 }
105 
106 pub struct IsNotEmpty;
107 
108 impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty {
109     type Output = (u8, u8);
110 
111     #[inline]
call_once(mut self, arg: (&'a &'b [u16],)) -> (u8, u8)112     extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> (u8, u8) {
113         self.call_mut(arg)
114     }
115 }
116 
117 impl<'a, 'b> FnMut<(&'a &'b [u16],)> for IsNotEmpty {
118     #[inline]
call_mut(&mut self, _arg: (&'a &'b [u16],)) -> (u8, u8)119     extern "rust-call" fn call_mut(&mut self, _arg: (&'a &'b [u16],)) -> (u8, u8) {
120         (0, 42)
121     }
122 }
123 
call_is_not_empty()124 pub fn call_is_not_empty() {
125     IsNotEmpty.call_once((&(&[0u16] as &[_]),));
126 }
127 
eq_char(a: char, b: char) -> bool128 pub fn eq_char(a: char, b: char) -> bool {
129     a == b
130 }
131 
transmute(c: char) -> u32132 pub unsafe fn transmute(c: char) -> u32 {
133     intrinsics::transmute(c)
134 }
135 
deref_str_ptr(s: *const str) -> &'static str136 pub unsafe fn deref_str_ptr(s: *const str) -> &'static str {
137     &*s
138 }
139 
use_array(arr: [u8; 3]) -> u8140 pub fn use_array(arr: [u8; 3]) -> u8 {
141     arr[1]
142 }
143 
repeat_array() -> [u8; 3]144 pub fn repeat_array() -> [u8; 3] {
145     [0; 3]
146 }
147 
array_as_slice(arr: &[u8; 3]) -> &[u8]148 pub fn array_as_slice(arr: &[u8; 3]) -> &[u8] {
149     arr
150 }
151 
use_ctlz_nonzero(a: u16) -> u16152 pub unsafe fn use_ctlz_nonzero(a: u16) -> u16 {
153     intrinsics::ctlz_nonzero(a)
154 }
155 
ptr_as_usize(ptr: *const u8) -> usize156 pub fn ptr_as_usize(ptr: *const u8) -> usize {
157     ptr as usize
158 }
159 
float_cast(a: f32, b: f64) -> (f64, f32)160 pub fn float_cast(a: f32, b: f64) -> (f64, f32) {
161     (a as f64, b as f32)
162 }
163 
int_to_float(a: u8, b: i32) -> (f64, f32)164 pub fn int_to_float(a: u8, b: i32) -> (f64, f32) {
165     (a as f64, b as f32)
166 }
167 
make_array() -> [u8; 3]168 pub fn make_array() -> [u8; 3] {
169     [42, 0, 5]
170 }
171 
some_promoted_tuple() -> &'static (&'static str, &'static str)172 pub fn some_promoted_tuple() -> &'static (&'static str, &'static str) {
173     &("abc", "some")
174 }
175 
index_slice(s: &[u8]) -> u8176 pub fn index_slice(s: &[u8]) -> u8 {
177     s[2]
178 }
179 
180 pub struct StrWrapper {
181     s: str,
182 }
183 
str_wrapper_get(w: &StrWrapper) -> &str184 pub fn str_wrapper_get(w: &StrWrapper) -> &str {
185     &w.s
186 }
187 
i16_as_i8(a: i16) -> i8188 pub fn i16_as_i8(a: i16) -> i8 {
189     a as i8
190 }
191 
192 pub struct Unsized(u8, str);
193 
get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8194 pub fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 {
195     &u.0
196 }
197 
get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str198 pub fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str {
199     &u.1
200 }
201 
reuse_byref_argument_storage(a: (u8, u16, u32)) -> u8202 pub fn reuse_byref_argument_storage(a: (u8, u16, u32)) -> u8 {
203     a.0
204 }
205