10 #![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics)]
19 // Because we don't have core yet.
27 impl Copy for isize {}
28 impl Copy for usize {}
39 pub(crate) unsafe auto trait Freeze {}
44 pub fn printf(format: *const i8, ...) -> i32;
45 pub fn puts(s: *const u8) -> i32;
50 pub trait Index<Idx: ?Sized> {
52 fn index(&self, index: Idx) -> &Self::Output;
55 impl<T> Index<usize> for [T; 3] {
58 fn index(&self, index: usize) -> &Self::Output {
63 impl<T> Index<usize> for [T] {
66 fn index(&self, index: usize) -> &Self::Output {
71 #[lang = "drop_in_place"]
72 #[allow(unconditional_recursion)]
73 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
74 // Code here does not matter - this is replaced by the
75 // real drop glue by the compiler.
76 drop_in_place(to_drop);
82 pub fn panic(_msg: &str) -> ! {
84 libc::puts("Panicking\0" as *const str as *const u8);
89 #[lang = "panic_location"]
90 struct PanicLocation {
96 #[lang = "panic_bounds_check"]
99 fn panic_bounds_check(index: usize, len: usize) -> ! {
101 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);
107 extern "rust-intrinsic" {
113 trait Add<RHS = Self> {
116 fn add(self, rhs: RHS) -> Self::Output;
122 fn add(self, rhs: Self) -> Self {
130 fn add(self, rhs: Self) -> Self {
138 fn add(self, rhs: Self) -> Self {
146 fn add(self, rhs: Self) -> Self {
154 fn add(self, rhs: Self) -> Self {
160 pub trait Sub<RHS = Self> {
163 fn sub(self, rhs: RHS) -> Self::Output;
169 fn sub(self, rhs: Self) -> Self {
177 fn sub(self, rhs: Self) -> Self {
185 fn sub(self, rhs: Self) -> Self {
193 fn sub(self, rhs: Self) -> Self {
201 fn sub(self, rhs: Self) -> Self {
211 static mut ONE: usize = 1;
213 fn make_array() -> [u8; 3] {
218 fn main(argc: isize, _argv: *const *const u8) -> isize {
219 let array = [42, 7, 5];
220 let array2 = make_array();
222 libc::printf(b"%ld\n\0" as *const u8 as *const i8, array[ONE - 1]);
223 libc::printf(b"%ld\n\0" as *const u8 as *const i8, array[ONE]);
224 libc::printf(b"%ld\n\0" as *const u8 as *const i8, array[ONE + 1]);
226 libc::printf(b"%d\n\0" as *const u8 as *const i8, array2[argc as usize] as u32);