]> git.lizzy.rs Git - rust.git/blobdiff - example/mini_core.rs
Merge pull request #1057 from spastorino/store-pairs-in-ssa
[rust.git] / example / mini_core.rs
index 8abb72dc786966514904f620508dbb48c86997f6..a8db81fa06d595e3ef5e89d5a0afc77a76a3aad3 100644 (file)
@@ -85,6 +85,12 @@ unsafe impl<T: ?Sized> Freeze for *mut T {}
 unsafe impl<T: ?Sized> Freeze for &T {}
 unsafe impl<T: ?Sized> Freeze for &mut T {}
 
+#[lang = "structural_peq"]
+pub trait StructuralPartialEq {}
+
+#[lang = "structural_teq"]
+pub trait StructuralEq {}
+
 #[lang = "not"]
 pub trait Not {
     type Output;
@@ -382,6 +388,7 @@ pub enum Option<T> {
 #[lang = "fn_once"]
 #[rustc_paren_sugar]
 pub trait FnOnce<Args> {
+    #[lang = "fn_once_output"]
     type Output;
 
     extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
@@ -394,9 +401,19 @@ pub trait FnMut<Args>: FnOnce<Args> {
 }
 
 #[lang = "panic"]
-pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! {
+#[track_caller]
+pub fn panic(_msg: &str) -> ! {
+    unsafe {
+        libc::puts("Panicking\n\0" as *const str as *const i8);
+        intrinsics::abort();
+    }
+}
+
+#[lang = "panic_bounds_check"]
+#[track_caller]
+fn panic_bounds_check(index: usize, len: usize) -> ! {
     unsafe {
-        libc::puts("Panicking\0" as *const str as *const u8);
+        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);
         intrinsics::abort();
     }
 }
@@ -472,22 +489,24 @@ pub mod intrinsics {
     extern "rust-intrinsic" {
         pub fn abort() -> !;
         pub fn size_of<T>() -> usize;
-        pub fn size_of_val<T: ?::Sized>(val: &T) -> usize;
+        pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
         pub fn min_align_of<T>() -> usize;
-        pub fn min_align_of_val<T: ?::Sized>(val: &T) -> usize;
+        pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
         pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
         pub fn transmute<T, U>(e: T) -> U;
         pub fn ctlz_nonzero<T>(x: T) -> T;
         pub fn needs_drop<T>() -> bool;
         pub fn bitreverse<T>(x: T) -> T;
         pub fn bswap<T>(x: T) -> T;
+        pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
     }
 }
 
 pub mod libc {
-    #[link(name = "c")]
+    #[cfg_attr(not(windows), link(name = "c"))]
+    #[cfg_attr(windows, link(name = "msvcrt"))]
     extern "C" {
-        pub fn puts(s: *const u8);
+        pub fn puts(s: *const i8) -> i32;
         pub fn printf(format: *const i8, ...) -> i32;
         pub fn malloc(size: usize) -> *mut u8;
         pub fn free(ptr: *mut u8);