23 pub trait Unsize<T: ?Sized> {}
25 #[lang = "coerce_unsized"]
26 pub trait CoerceUnsized<T> {}
28 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
29 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
30 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
31 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
33 #[lang = "dispatch_from_dyn"]
34 pub trait DispatchFromDyn<T> {}
37 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
39 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
40 // *const T -> *const U
41 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
43 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
44 impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
49 impl<T: ?Sized> Receiver for &T {}
50 impl<T: ?Sized> Receiver for &mut T {}
51 impl<T: ?Sized> Receiver for Box<T> {}
54 pub unsafe trait Copy {}
56 unsafe impl Copy for bool {}
57 unsafe impl Copy for u8 {}
58 unsafe impl Copy for u16 {}
59 unsafe impl Copy for u32 {}
60 unsafe impl Copy for u64 {}
61 unsafe impl Copy for u128 {}
62 unsafe impl Copy for usize {}
63 unsafe impl Copy for i8 {}
64 unsafe impl Copy for i16 {}
65 unsafe impl Copy for i32 {}
66 unsafe impl Copy for isize {}
67 unsafe impl Copy for f32 {}
68 unsafe impl Copy for f64 {}
69 unsafe impl Copy for char {}
70 unsafe impl<'a, T: ?Sized> Copy for &'a T {}
71 unsafe impl<T: ?Sized> Copy for *const T {}
72 unsafe impl<T: ?Sized> Copy for *mut T {}
73 unsafe impl<T: Copy> Copy for Option<T> {}
76 pub unsafe trait Sync {}
78 unsafe impl Sync for bool {}
79 unsafe impl Sync for u8 {}
80 unsafe impl Sync for u16 {}
81 unsafe impl Sync for u32 {}
82 unsafe impl Sync for u64 {}
83 unsafe impl Sync for usize {}
84 unsafe impl Sync for i8 {}
85 unsafe impl Sync for i16 {}
86 unsafe impl Sync for i32 {}
87 unsafe impl Sync for isize {}
88 unsafe impl Sync for char {}
89 unsafe impl<'a, T: ?Sized> Sync for &'a T {}
90 unsafe impl Sync for [u8; 16] {}
93 unsafe auto trait Freeze {}
95 unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
96 unsafe impl<T: ?Sized> Freeze for *const T {}
97 unsafe impl<T: ?Sized> Freeze for *mut T {}
98 unsafe impl<T: ?Sized> Freeze for &T {}
99 unsafe impl<T: ?Sized> Freeze for &mut T {}
101 #[lang = "structural_peq"]
102 pub trait StructuralPartialEq {}
104 #[lang = "structural_teq"]
105 pub trait StructuralEq {}
111 fn not(self) -> Self::Output;
117 fn not(self) -> bool {
123 pub trait Mul<RHS = Self> {
127 fn mul(self, rhs: RHS) -> Self::Output;
133 fn mul(self, rhs: Self) -> Self::Output {
141 fn mul(self, rhs: Self) -> Self::Output {
147 pub trait Add<RHS = Self> {
150 fn add(self, rhs: RHS) -> Self::Output;
156 fn add(self, rhs: Self) -> Self {
164 fn add(self, rhs: Self) -> Self {
172 fn add(self, rhs: Self) -> Self {
178 pub trait Sub<RHS = Self> {
181 fn sub(self, rhs: RHS) -> Self::Output;
187 fn sub(self, rhs: Self) -> Self {
195 fn sub(self, rhs: Self) -> Self {
203 fn sub(self, rhs: Self) -> Self {
211 fn sub(self, rhs: Self) -> Self {
217 pub trait Rem<RHS = Self> {
220 fn rem(self, rhs: RHS) -> Self::Output;
226 fn rem(self, rhs: Self) -> Self {
232 pub trait BitOr<RHS = Self> {
236 fn bitor(self, rhs: RHS) -> Self::Output;
239 impl BitOr for bool {
242 fn bitor(self, rhs: bool) -> bool {
247 impl<'a> BitOr<bool> for &'a bool {
250 fn bitor(self, rhs: bool) -> bool {
256 pub trait PartialEq<Rhs: ?Sized = Self> {
257 fn eq(&self, other: &Rhs) -> bool;
258 fn ne(&self, other: &Rhs) -> bool;
261 impl PartialEq for u8 {
262 fn eq(&self, other: &u8) -> bool {
265 fn ne(&self, other: &u8) -> bool {
270 impl PartialEq for u16 {
271 fn eq(&self, other: &u16) -> bool {
274 fn ne(&self, other: &u16) -> bool {
279 impl PartialEq for u32 {
280 fn eq(&self, other: &u32) -> bool {
283 fn ne(&self, other: &u32) -> bool {
289 impl PartialEq for u64 {
290 fn eq(&self, other: &u64) -> bool {
293 fn ne(&self, other: &u64) -> bool {
298 impl PartialEq for u128 {
299 fn eq(&self, other: &u128) -> bool {
302 fn ne(&self, other: &u128) -> bool {
307 impl PartialEq for usize {
308 fn eq(&self, other: &usize) -> bool {
311 fn ne(&self, other: &usize) -> bool {
316 impl PartialEq for i8 {
317 fn eq(&self, other: &i8) -> bool {
320 fn ne(&self, other: &i8) -> bool {
325 impl PartialEq for i32 {
326 fn eq(&self, other: &i32) -> bool {
329 fn ne(&self, other: &i32) -> bool {
334 impl PartialEq for isize {
335 fn eq(&self, other: &isize) -> bool {
338 fn ne(&self, other: &isize) -> bool {
343 impl PartialEq for char {
344 fn eq(&self, other: &char) -> bool {
347 fn ne(&self, other: &char) -> bool {
352 impl<T: ?Sized> PartialEq for *const T {
353 fn eq(&self, other: &*const T) -> bool {
356 fn ne(&self, other: &*const T) -> bool {
361 impl <T: PartialEq> PartialEq for Option<T> {
362 fn eq(&self, other: &Self) -> bool {
363 match (self, other) {
364 (Some(lhs), Some(rhs)) => *lhs == *rhs,
365 (None, None) => true,
370 fn ne(&self, other: &Self) -> bool {
371 match (self, other) {
372 (Some(lhs), Some(rhs)) => *lhs != *rhs,
373 (None, None) => false,
380 pub trait Shl<RHS = Self> {
384 fn shl(self, rhs: RHS) -> Self::Output;
390 fn shl(self, rhs: u128) -> u128 {
399 fn neg(self) -> Self::Output;
413 fn neg(self) -> i16 {
421 fn neg(self) -> isize {
429 fn neg(self) -> f32 {
441 #[lang = "phantom_data"]
442 pub struct PhantomData<T: ?Sized>;
446 pub trait FnOnce<Args> {
447 #[lang = "fn_once_output"]
450 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
455 pub trait FnMut<Args>: FnOnce<Args> {
456 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
461 pub fn panic(_msg: &str) -> ! {
463 libc::puts("Panicking\n\0" as *const str as *const i8);
468 #[lang = "panic_bounds_check"]
470 fn panic_bounds_check(index: usize, len: usize) -> ! {
472 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);
477 #[lang = "eh_personality"]
478 fn eh_personality() -> ! {
482 #[lang = "drop_in_place"]
483 #[allow(unconditional_recursion)]
484 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
485 // Code here does not matter - this is replaced by the
486 // real drop glue by the compiler.
487 drop_in_place(to_drop);
494 fn deref(&self) -> &Self::Target;
498 #[rustc_layout_scalar_valid_range_start(1)]
499 #[rustc_nonnull_optimization_guaranteed]
500 pub struct NonNull<T: ?Sized>(pub *mut T);
502 impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
503 impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
505 pub struct Unique<T: ?Sized> {
506 pub pointer: NonNull<T>,
507 pub _marker: PhantomData<T>,
510 impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
511 impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
513 #[lang = "owned_box"]
514 pub struct Box<T: ?Sized>(Unique<T>, ());
516 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
518 impl<T: ?Sized> Drop for Box<T> {
520 // drop is currently performed by compiler.
524 impl<T> Deref for Box<T> {
527 fn deref(&self) -> &Self::Target {
532 #[lang = "exchange_malloc"]
533 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
538 unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
539 libc::free(ptr.pointer.0 as *mut u8);
547 #[lang = "manually_drop"]
549 pub struct ManuallyDrop<T: ?Sized> {
553 #[lang = "maybe_uninit"]
555 pub union MaybeUninit<T> {
557 pub value: ManuallyDrop<T>,
561 extern "rust-intrinsic" {
563 pub fn size_of<T>() -> usize;
564 pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
565 pub fn min_align_of<T>() -> usize;
566 pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
567 pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
568 pub fn transmute<T, U>(e: T) -> U;
569 pub fn ctlz_nonzero<T>(x: T) -> T;
570 pub fn needs_drop<T>() -> bool;
571 pub fn bitreverse<T>(x: T) -> T;
572 pub fn bswap<T>(x: T) -> T;
573 pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
578 #[cfg_attr(unix, link(name = "c"))]
579 #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
581 pub fn puts(s: *const i8) -> i32;
582 pub fn printf(format: *const i8, ...) -> i32;
583 pub fn malloc(size: usize) -> *mut u8;
584 pub fn free(ptr: *mut u8);
585 pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
586 pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
587 pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
592 pub trait Index<Idx: ?Sized> {
594 fn index(&self, index: Idx) -> &Self::Output;
597 impl<T> Index<usize> for [T; 3] {
600 fn index(&self, index: usize) -> &Self::Output {
605 impl<T> Index<usize> for [T] {
608 fn index(&self, index: usize) -> &Self::Output {
619 pub struct VaList<'a>(&'a mut VaListImpl);
621 #[rustc_builtin_macro]
622 #[rustc_macro_transparency = "semitransparent"]
623 pub macro stringify($($t:tt)*) { /* compiler built-in */ }
625 #[rustc_builtin_macro]
626 #[rustc_macro_transparency = "semitransparent"]
627 pub macro file() { /* compiler built-in */ }
629 #[rustc_builtin_macro]
630 #[rustc_macro_transparency = "semitransparent"]
631 pub macro line() { /* compiler built-in */ }
633 #[rustc_builtin_macro]
634 #[rustc_macro_transparency = "semitransparent"]
635 pub macro cfg() { /* compiler built-in */ }
637 #[rustc_builtin_macro]
638 #[rustc_macro_transparency = "semitransparent"]
639 pub macro global_asm() { /* compiler built-in */ }
641 pub static A_STATIC: u8 = 42;
643 #[lang = "panic_location"]
644 struct PanicLocation {
652 pub fn get_tls() -> u8 {