7 #![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics)]
16 // Because we don't have core yet.
24 impl Copy for isize {}
25 impl Copy for usize {}
36 pub(crate) unsafe auto trait Freeze {}
41 pub fn printf(format: *const i8, ...) -> i32;
42 pub fn puts(s: *const u8) -> i32;
47 pub trait Index<Idx: ?Sized> {
49 fn index(&self, index: Idx) -> &Self::Output;
52 impl<T> Index<usize> for [T; 3] {
55 fn index(&self, index: usize) -> &Self::Output {
60 impl<T> Index<usize> for [T] {
63 fn index(&self, index: usize) -> &Self::Output {
68 #[lang = "drop_in_place"]
69 #[allow(unconditional_recursion)]
70 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
71 // Code here does not matter - this is replaced by the
72 // real drop glue by the compiler.
73 drop_in_place(to_drop);
79 pub fn panic(_msg: &str) -> ! {
81 libc::puts("Panicking\0" as *const str as *const u8);
86 #[lang = "panic_location"]
87 struct PanicLocation {
93 #[lang = "panic_bounds_check"]
96 fn panic_bounds_check(index: usize, len: usize) -> ! {
98 libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index);
104 extern "rust-intrinsic" {
110 trait Add<RHS = Self> {
113 fn add(self, rhs: RHS) -> Self::Output;
119 fn add(self, rhs: Self) -> Self {
127 fn add(self, rhs: Self) -> Self {
135 fn add(self, rhs: Self) -> Self {
143 fn add(self, rhs: Self) -> Self {
151 fn add(self, rhs: Self) -> Self {
157 pub trait Sub<RHS = Self> {
160 fn sub(self, rhs: RHS) -> Self::Output;
166 fn sub(self, rhs: Self) -> Self {
174 fn sub(self, rhs: Self) -> Self {
182 fn sub(self, rhs: Self) -> Self {
190 fn sub(self, rhs: Self) -> Self {
198 fn sub(self, rhs: Self) -> Self {
208 fn i16_as_i8(a: i16) -> i8 {
212 fn call_func(func: fn(i16) -> i8, param: i16) -> i8 {
217 fn main(argc: isize, _argv: *const *const u8) -> isize {
219 let result = call_func(i16_as_i8, argc as i16) as isize;
220 libc::printf(b"%ld\n\0" as *const u8 as *const i8, result);