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;
#[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;
}
#[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();
}
}
}
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);