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 {}
34 pub(crate) unsafe auto trait Freeze {}
39 pub fn printf(format: *const i8, ...) -> i32;
44 pub trait Index<Idx: ?Sized> {
46 fn index(&self, index: Idx) -> &Self::Output;
49 impl<T> Index<usize> for [T; 3] {
52 fn index(&self, index: usize) -> &Self::Output {
57 impl<T> Index<usize> for [T] {
60 fn index(&self, index: usize) -> &Self::Output {
66 pub trait Unsize<T: ?Sized> {}
68 #[lang = "coerce_unsized"]
69 pub trait CoerceUnsized<T> {}
71 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
72 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
73 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
74 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
76 #[lang = "drop_in_place"]
77 #[allow(unconditional_recursion)]
78 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
79 // Code here does not matter - this is replaced by the
80 // real drop glue by the compiler.
81 drop_in_place(to_drop);
84 #[lang = "panic_location"]
85 struct PanicLocation {
91 #[lang = "panic_bounds_check"]
94 fn panic_bounds_check(index: usize, len: usize) -> ! {
96 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" {
113 static mut TWO: usize = 2;
115 fn index_slice(s: &[u32]) -> u32 {
122 fn main(mut argc: isize, _argv: *const *const u8) -> isize {
123 let array = [42, 7, 5];
125 libc::printf(b"%ld\n\0" as *const u8 as *const i8, index_slice(&array));