22 #[lang = "tuple_trait"]
26 pub trait Unsize<T: ?Sized> {}
28 #[lang = "coerce_unsized"]
29 pub trait CoerceUnsized<T> {}
31 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
32 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
33 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
34 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
36 #[lang = "dispatch_from_dyn"]
37 pub trait DispatchFromDyn<T> {}
40 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
42 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
43 // *const T -> *const U
44 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
46 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
47 impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
52 impl<T: ?Sized> Receiver for &T {}
53 impl<T: ?Sized> Receiver for &mut T {}
54 impl<T: ?Sized> Receiver for Box<T> {}
57 pub unsafe trait Copy {}
59 unsafe impl Copy for bool {}
60 unsafe impl Copy for u8 {}
61 unsafe impl Copy for u16 {}
62 unsafe impl Copy for u32 {}
63 unsafe impl Copy for u64 {}
64 unsafe impl Copy for u128 {}
65 unsafe impl Copy for usize {}
66 unsafe impl Copy for i8 {}
67 unsafe impl Copy for i16 {}
68 unsafe impl Copy for i32 {}
69 unsafe impl Copy for isize {}
70 unsafe impl Copy for f32 {}
71 unsafe impl Copy for f64 {}
72 unsafe impl Copy for char {}
73 unsafe impl<'a, T: ?Sized> Copy for &'a T {}
74 unsafe impl<T: ?Sized> Copy for *const T {}
75 unsafe impl<T: ?Sized> Copy for *mut T {}
76 unsafe impl<T: Copy> Copy for Option<T> {}
79 pub unsafe trait Sync {}
81 unsafe impl Sync for bool {}
82 unsafe impl Sync for u8 {}
83 unsafe impl Sync for u16 {}
84 unsafe impl Sync for u32 {}
85 unsafe impl Sync for u64 {}
86 unsafe impl Sync for usize {}
87 unsafe impl Sync for i8 {}
88 unsafe impl Sync for i16 {}
89 unsafe impl Sync for i32 {}
90 unsafe impl Sync for isize {}
91 unsafe impl Sync for char {}
92 unsafe impl<'a, T: ?Sized> Sync for &'a T {}
93 unsafe impl Sync for [u8; 16] {}
96 unsafe auto trait Freeze {}
98 unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
99 unsafe impl<T: ?Sized> Freeze for *const T {}
100 unsafe impl<T: ?Sized> Freeze for *mut T {}
101 unsafe impl<T: ?Sized> Freeze for &T {}
102 unsafe impl<T: ?Sized> Freeze for &mut T {}
104 #[lang = "structural_peq"]
105 pub trait StructuralPartialEq {}
107 #[lang = "structural_teq"]
108 pub trait StructuralEq {}
114 fn not(self) -> Self::Output;
120 fn not(self) -> bool {
126 pub trait Mul<RHS = Self> {
130 fn mul(self, rhs: RHS) -> Self::Output;
136 fn mul(self, rhs: Self) -> Self::Output {
144 fn mul(self, rhs: Self) -> Self::Output {
150 pub trait Add<RHS = Self> {
153 fn add(self, rhs: RHS) -> Self::Output;
159 fn add(self, rhs: Self) -> Self {
167 fn add(self, rhs: Self) -> Self {
175 fn add(self, rhs: Self) -> Self {
181 pub trait Sub<RHS = Self> {
184 fn sub(self, rhs: RHS) -> Self::Output;
190 fn sub(self, rhs: Self) -> Self {
198 fn sub(self, rhs: Self) -> Self {
206 fn sub(self, rhs: Self) -> Self {
214 fn sub(self, rhs: Self) -> Self {
220 pub trait Rem<RHS = Self> {
223 fn rem(self, rhs: RHS) -> Self::Output;
229 fn rem(self, rhs: Self) -> Self {
235 pub trait BitOr<RHS = Self> {
239 fn bitor(self, rhs: RHS) -> Self::Output;
242 impl BitOr for bool {
245 fn bitor(self, rhs: bool) -> bool {
250 impl<'a> BitOr<bool> for &'a bool {
253 fn bitor(self, rhs: bool) -> bool {
259 pub trait PartialEq<Rhs: ?Sized = Self> {
260 fn eq(&self, other: &Rhs) -> bool;
261 fn ne(&self, other: &Rhs) -> bool;
264 impl PartialEq for u8 {
265 fn eq(&self, other: &u8) -> bool {
268 fn ne(&self, other: &u8) -> bool {
273 impl PartialEq for u16 {
274 fn eq(&self, other: &u16) -> bool {
277 fn ne(&self, other: &u16) -> bool {
282 impl PartialEq for u32 {
283 fn eq(&self, other: &u32) -> bool {
286 fn ne(&self, other: &u32) -> bool {
292 impl PartialEq for u64 {
293 fn eq(&self, other: &u64) -> bool {
296 fn ne(&self, other: &u64) -> bool {
301 impl PartialEq for u128 {
302 fn eq(&self, other: &u128) -> bool {
305 fn ne(&self, other: &u128) -> bool {
310 impl PartialEq for usize {
311 fn eq(&self, other: &usize) -> bool {
314 fn ne(&self, other: &usize) -> bool {
319 impl PartialEq for i8 {
320 fn eq(&self, other: &i8) -> bool {
323 fn ne(&self, other: &i8) -> bool {
328 impl PartialEq for i32 {
329 fn eq(&self, other: &i32) -> bool {
332 fn ne(&self, other: &i32) -> bool {
337 impl PartialEq for isize {
338 fn eq(&self, other: &isize) -> bool {
341 fn ne(&self, other: &isize) -> bool {
346 impl PartialEq for char {
347 fn eq(&self, other: &char) -> bool {
350 fn ne(&self, other: &char) -> bool {
355 impl<T: ?Sized> PartialEq for *const T {
356 fn eq(&self, other: &*const T) -> bool {
359 fn ne(&self, other: &*const T) -> bool {
364 impl <T: PartialEq> PartialEq for Option<T> {
365 fn eq(&self, other: &Self) -> bool {
366 match (self, other) {
367 (Some(lhs), Some(rhs)) => *lhs == *rhs,
368 (None, None) => true,
373 fn ne(&self, other: &Self) -> bool {
374 match (self, other) {
375 (Some(lhs), Some(rhs)) => *lhs != *rhs,
376 (None, None) => false,
383 pub trait Shl<RHS = Self> {
387 fn shl(self, rhs: RHS) -> Self::Output;
393 fn shl(self, rhs: u128) -> u128 {
402 fn neg(self) -> Self::Output;
416 fn neg(self) -> i16 {
424 fn neg(self) -> isize {
432 fn neg(self) -> f32 {
444 #[lang = "phantom_data"]
445 pub struct PhantomData<T: ?Sized>;
449 pub trait FnOnce<Args: Tuple> {
450 #[lang = "fn_once_output"]
453 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
458 pub trait FnMut<Args: Tuple>: FnOnce<Args> {
459 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
464 pub fn panic(_msg: &'static str) -> ! {
466 libc::puts("Panicking\n\0" as *const str as *const i8);
471 #[lang = "panic_bounds_check"]
473 fn panic_bounds_check(index: usize, len: usize) -> ! {
475 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);
480 #[lang = "eh_personality"]
481 fn eh_personality() -> ! {
485 #[lang = "drop_in_place"]
486 #[allow(unconditional_recursion)]
487 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
488 // Code here does not matter - this is replaced by the
489 // real drop glue by the compiler.
490 drop_in_place(to_drop);
497 fn deref(&self) -> &Self::Target;
501 #[rustc_layout_scalar_valid_range_start(1)]
502 #[rustc_nonnull_optimization_guaranteed]
503 pub struct NonNull<T: ?Sized>(pub *const T);
505 impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
506 impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
508 pub struct Unique<T: ?Sized> {
509 pub pointer: NonNull<T>,
510 pub _marker: PhantomData<T>,
513 impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
514 impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
516 #[lang = "owned_box"]
517 pub struct Box<T: ?Sized>(Unique<T>, ());
519 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
521 impl<T: ?Sized> Drop for Box<T> {
523 // drop is currently performed by compiler.
527 impl<T: ?Sized> Deref for Box<T> {
530 fn deref(&self) -> &Self::Target {
535 #[lang = "exchange_malloc"]
536 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
541 unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, _alloc: ()) {
542 libc::free(ptr.pointer.0 as *mut u8);
550 #[lang = "manually_drop"]
552 pub struct ManuallyDrop<T: ?Sized> {
556 #[lang = "maybe_uninit"]
558 pub union MaybeUninit<T> {
560 pub value: ManuallyDrop<T>,
564 extern "rust-intrinsic" {
565 #[rustc_safe_intrinsic]
567 #[rustc_safe_intrinsic]
568 pub fn size_of<T>() -> usize;
569 pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
570 #[rustc_safe_intrinsic]
571 pub fn min_align_of<T>() -> usize;
572 pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
573 pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
574 pub fn transmute<T, U>(e: T) -> U;
575 pub fn ctlz_nonzero<T>(x: T) -> T;
576 #[rustc_safe_intrinsic]
577 pub fn needs_drop<T: ?::Sized>() -> bool;
578 #[rustc_safe_intrinsic]
579 pub fn bitreverse<T>(x: T) -> T;
580 #[rustc_safe_intrinsic]
581 pub fn bswap<T>(x: T) -> T;
582 pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
587 // With the new Universal CRT, msvc has switched to all the printf functions being inline wrapper
588 // functions. legacy_stdio_definitions.lib which provides the printf wrapper functions as normal
589 // symbols to link against.
590 #[cfg_attr(unix, link(name = "c"))]
591 #[cfg_attr(target_env="msvc", link(name="legacy_stdio_definitions"))]
593 pub fn printf(format: *const i8, ...) -> i32;
596 #[cfg_attr(unix, link(name = "c"))]
597 #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
599 pub fn puts(s: *const i8) -> i32;
600 pub fn malloc(size: usize) -> *mut u8;
601 pub fn free(ptr: *mut u8);
602 pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
603 pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
604 pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
609 pub trait Index<Idx: ?Sized> {
611 fn index(&self, index: Idx) -> &Self::Output;
614 impl<T> Index<usize> for [T; 3] {
617 fn index(&self, index: usize) -> &Self::Output {
622 impl<T> Index<usize> for [T] {
625 fn index(&self, index: usize) -> &Self::Output {
636 pub struct VaList<'a>(&'a mut VaListImpl);
638 #[rustc_builtin_macro]
639 #[rustc_macro_transparency = "semitransparent"]
640 pub macro stringify($($t:tt)*) { /* compiler built-in */ }
642 #[rustc_builtin_macro]
643 #[rustc_macro_transparency = "semitransparent"]
644 pub macro file() { /* compiler built-in */ }
646 #[rustc_builtin_macro]
647 #[rustc_macro_transparency = "semitransparent"]
648 pub macro line() { /* compiler built-in */ }
650 #[rustc_builtin_macro]
651 #[rustc_macro_transparency = "semitransparent"]
652 pub macro cfg() { /* compiler built-in */ }
654 #[rustc_builtin_macro]
655 #[rustc_macro_transparency = "semitransparent"]
656 pub macro global_asm() { /* compiler built-in */ }
658 pub static A_STATIC: u8 = 42;
660 #[lang = "panic_location"]
661 struct PanicLocation {
669 pub fn get_tls() -> u8 {