20 pub trait Unsize<T: ?Sized> {}
22 #[lang = "coerce_unsized"]
23 pub trait CoerceUnsized<T> {}
25 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
26 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
27 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
28 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
30 #[lang = "dispatch_from_dyn"]
31 pub trait DispatchFromDyn<T> {}
34 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
36 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
37 // *const T -> *const U
38 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
40 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
41 impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
46 impl<T: ?Sized> Receiver for &T {}
47 impl<T: ?Sized> Receiver for &mut T {}
48 impl<T: ?Sized> Receiver for Box<T> {}
51 pub unsafe trait Copy {}
53 unsafe impl Copy for bool {}
54 unsafe impl Copy for u8 {}
55 unsafe impl Copy for u16 {}
56 unsafe impl Copy for u32 {}
57 unsafe impl Copy for u64 {}
58 unsafe impl Copy for u128 {}
59 unsafe impl Copy for usize {}
60 unsafe impl Copy for i8 {}
61 unsafe impl Copy for i16 {}
62 unsafe impl Copy for i32 {}
63 unsafe impl Copy for isize {}
64 unsafe impl Copy for f32 {}
65 unsafe impl Copy for f64 {}
66 unsafe impl Copy for char {}
67 unsafe impl<'a, T: ?Sized> Copy for &'a T {}
68 unsafe impl<T: ?Sized> Copy for *const T {}
69 unsafe impl<T: ?Sized> Copy for *mut T {}
70 unsafe impl<T: Copy> Copy for Option<T> {}
73 pub unsafe trait Sync {}
75 unsafe impl Sync for bool {}
76 unsafe impl Sync for u8 {}
77 unsafe impl Sync for u16 {}
78 unsafe impl Sync for u32 {}
79 unsafe impl Sync for u64 {}
80 unsafe impl Sync for usize {}
81 unsafe impl Sync for i8 {}
82 unsafe impl Sync for i16 {}
83 unsafe impl Sync for i32 {}
84 unsafe impl Sync for isize {}
85 unsafe impl Sync for char {}
86 unsafe impl<'a, T: ?Sized> Sync for &'a T {}
87 unsafe impl Sync for [u8; 16] {}
90 unsafe auto trait Freeze {}
92 unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
93 unsafe impl<T: ?Sized> Freeze for *const T {}
94 unsafe impl<T: ?Sized> Freeze for *mut T {}
95 unsafe impl<T: ?Sized> Freeze for &T {}
96 unsafe impl<T: ?Sized> Freeze for &mut T {}
98 #[lang = "structural_peq"]
99 pub trait StructuralPartialEq {}
101 #[lang = "structural_teq"]
102 pub trait StructuralEq {}
108 fn not(self) -> Self::Output;
114 fn not(self) -> bool {
120 pub trait Mul<RHS = Self> {
124 fn mul(self, rhs: RHS) -> Self::Output;
130 fn mul(self, rhs: Self) -> Self::Output {
138 fn mul(self, rhs: Self) -> Self::Output {
144 pub trait Add<RHS = Self> {
147 fn add(self, rhs: RHS) -> Self::Output;
153 fn add(self, rhs: Self) -> Self {
161 fn add(self, rhs: Self) -> Self {
169 fn add(self, rhs: Self) -> Self {
175 pub trait Sub<RHS = Self> {
178 fn sub(self, rhs: RHS) -> Self::Output;
184 fn sub(self, rhs: Self) -> Self {
192 fn sub(self, rhs: Self) -> Self {
200 fn sub(self, rhs: Self) -> Self {
208 fn sub(self, rhs: Self) -> Self {
214 pub trait Rem<RHS = Self> {
217 fn rem(self, rhs: RHS) -> Self::Output;
223 fn rem(self, rhs: Self) -> Self {
229 pub trait BitOr<RHS = Self> {
233 fn bitor(self, rhs: RHS) -> Self::Output;
236 impl BitOr for bool {
239 fn bitor(self, rhs: bool) -> bool {
244 impl<'a> BitOr<bool> for &'a bool {
247 fn bitor(self, rhs: bool) -> bool {
253 pub trait PartialEq<Rhs: ?Sized = Self> {
254 fn eq(&self, other: &Rhs) -> bool;
255 fn ne(&self, other: &Rhs) -> bool;
258 impl PartialEq for u8 {
259 fn eq(&self, other: &u8) -> bool {
262 fn ne(&self, other: &u8) -> bool {
267 impl PartialEq for u16 {
268 fn eq(&self, other: &u16) -> bool {
271 fn ne(&self, other: &u16) -> bool {
276 impl PartialEq for u32 {
277 fn eq(&self, other: &u32) -> bool {
280 fn ne(&self, other: &u32) -> bool {
286 impl PartialEq for u64 {
287 fn eq(&self, other: &u64) -> bool {
290 fn ne(&self, other: &u64) -> bool {
295 impl PartialEq for u128 {
296 fn eq(&self, other: &u128) -> bool {
299 fn ne(&self, other: &u128) -> bool {
304 impl PartialEq for usize {
305 fn eq(&self, other: &usize) -> bool {
308 fn ne(&self, other: &usize) -> bool {
313 impl PartialEq for i8 {
314 fn eq(&self, other: &i8) -> bool {
317 fn ne(&self, other: &i8) -> bool {
322 impl PartialEq for i32 {
323 fn eq(&self, other: &i32) -> bool {
326 fn ne(&self, other: &i32) -> bool {
331 impl PartialEq for isize {
332 fn eq(&self, other: &isize) -> bool {
335 fn ne(&self, other: &isize) -> bool {
340 impl PartialEq for char {
341 fn eq(&self, other: &char) -> bool {
344 fn ne(&self, other: &char) -> bool {
349 impl<T: ?Sized> PartialEq for *const T {
350 fn eq(&self, other: &*const T) -> bool {
353 fn ne(&self, other: &*const T) -> bool {
358 impl <T: PartialEq> PartialEq for Option<T> {
359 fn eq(&self, other: &Self) -> bool {
360 match (self, other) {
361 (Some(lhs), Some(rhs)) => *lhs == *rhs,
362 (None, None) => true,
367 fn ne(&self, other: &Self) -> bool {
368 match (self, other) {
369 (Some(lhs), Some(rhs)) => *lhs != *rhs,
370 (None, None) => false,
377 pub trait Shl<RHS = Self> {
381 fn shl(self, rhs: RHS) -> Self::Output;
387 fn shl(self, rhs: u128) -> u128 {
396 fn neg(self) -> Self::Output;
410 fn neg(self) -> i16 {
418 fn neg(self) -> isize {
426 fn neg(self) -> f32 {
438 #[lang = "phantom_data"]
439 pub struct PhantomData<T: ?Sized>;
443 pub trait FnOnce<Args> {
444 #[lang = "fn_once_output"]
447 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
452 pub trait FnMut<Args>: FnOnce<Args> {
453 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
458 pub fn panic(_msg: &str) -> ! {
460 libc::puts("Panicking\n\0" as *const str as *const i8);
465 #[lang = "panic_bounds_check"]
467 fn panic_bounds_check(index: usize, len: usize) -> ! {
469 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);
474 #[lang = "eh_personality"]
475 fn eh_personality() -> ! {
479 #[lang = "drop_in_place"]
480 #[allow(unconditional_recursion)]
481 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
482 // Code here does not matter - this is replaced by the
483 // real drop glue by the compiler.
484 drop_in_place(to_drop);
491 fn deref(&self) -> &Self::Target;
494 pub struct Unique<T: ?Sized> {
495 pub pointer: *const T,
496 pub _marker: PhantomData<T>,
499 impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
501 impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
503 #[lang = "owned_box"]
504 pub struct Box<T: ?Sized>(Unique<T>, ());
506 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
508 impl<T: ?Sized> Drop for Box<T> {
510 // drop is currently performed by compiler.
514 impl<T> Deref for Box<T> {
517 fn deref(&self) -> &Self::Target {
522 #[lang = "exchange_malloc"]
523 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
528 unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
529 libc::free(ptr.pointer as *mut u8);
537 #[lang = "manually_drop"]
539 pub struct ManuallyDrop<T: ?Sized> {
543 #[lang = "maybe_uninit"]
545 pub union MaybeUninit<T> {
547 pub value: ManuallyDrop<T>,
551 extern "rust-intrinsic" {
553 pub fn size_of<T>() -> usize;
554 pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
555 pub fn min_align_of<T>() -> usize;
556 pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
557 pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
558 pub fn transmute<T, U>(e: T) -> U;
559 pub fn ctlz_nonzero<T>(x: T) -> T;
560 pub fn needs_drop<T>() -> bool;
561 pub fn bitreverse<T>(x: T) -> T;
562 pub fn bswap<T>(x: T) -> T;
563 pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
568 #[cfg_attr(unix, link(name = "c"))]
569 #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
571 pub fn puts(s: *const i8) -> i32;
572 pub fn printf(format: *const i8, ...) -> i32;
573 pub fn malloc(size: usize) -> *mut u8;
574 pub fn free(ptr: *mut u8);
575 pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
576 pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
577 pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
582 pub trait Index<Idx: ?Sized> {
584 fn index(&self, index: Idx) -> &Self::Output;
587 impl<T> Index<usize> for [T; 3] {
590 fn index(&self, index: usize) -> &Self::Output {
595 impl<T> Index<usize> for [T] {
598 fn index(&self, index: usize) -> &Self::Output {
609 pub struct VaList<'a>(&'a mut VaListImpl);
611 #[rustc_builtin_macro]
612 #[rustc_macro_transparency = "semitransparent"]
613 pub macro stringify($($t:tt)*) { /* compiler built-in */ }
615 #[rustc_builtin_macro]
616 #[rustc_macro_transparency = "semitransparent"]
617 pub macro file() { /* compiler built-in */ }
619 #[rustc_builtin_macro]
620 #[rustc_macro_transparency = "semitransparent"]
621 pub macro line() { /* compiler built-in */ }
623 #[rustc_builtin_macro]
624 #[rustc_macro_transparency = "semitransparent"]
625 pub macro cfg() { /* compiler built-in */ }
627 #[rustc_builtin_macro]
628 #[rustc_macro_transparency = "semitransparent"]
629 pub macro global_asm() { /* compiler built-in */ }
631 pub static A_STATIC: u8 = 42;
633 #[lang = "panic_location"]
634 struct PanicLocation {
642 pub fn get_tls() -> u8 {