2 no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
3 untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
13 pub trait Unsize<T: ?Sized> {}
15 #[lang = "coerce_unsized"]
16 pub trait CoerceUnsized<T> {}
18 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
19 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
20 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
21 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
23 #[lang = "dispatch_from_dyn"]
24 pub trait DispatchFromDyn<T> {}
27 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
29 impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
30 // *const T -> *const U
31 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
33 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
34 impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
39 impl<T: ?Sized> Receiver for &T {}
40 impl<T: ?Sized> Receiver for &mut T {}
41 impl<T: ?Sized> Receiver for Box<T> {}
44 pub unsafe trait Copy {}
46 unsafe impl Copy for bool {}
47 unsafe impl Copy for u8 {}
48 unsafe impl Copy for u16 {}
49 unsafe impl Copy for u32 {}
50 unsafe impl Copy for u64 {}
51 unsafe impl Copy for u128 {}
52 unsafe impl Copy for usize {}
53 unsafe impl Copy for i8 {}
54 unsafe impl Copy for i16 {}
55 unsafe impl Copy for i32 {}
56 unsafe impl Copy for isize {}
57 unsafe impl Copy for f32 {}
58 unsafe impl Copy for char {}
59 unsafe impl<'a, T: ?Sized> Copy for &'a T {}
60 unsafe impl<T: ?Sized> Copy for *const T {}
61 unsafe impl<T: ?Sized> Copy for *mut T {}
62 unsafe impl<T: Copy> Copy for Option<T> {}
65 pub unsafe trait Sync {}
67 unsafe impl Sync for bool {}
68 unsafe impl Sync for u8 {}
69 unsafe impl Sync for u16 {}
70 unsafe impl Sync for u32 {}
71 unsafe impl Sync for u64 {}
72 unsafe impl Sync for usize {}
73 unsafe impl Sync for i8 {}
74 unsafe impl Sync for i16 {}
75 unsafe impl Sync for i32 {}
76 unsafe impl Sync for isize {}
77 unsafe impl Sync for char {}
78 unsafe impl<'a, T: ?Sized> Sync for &'a T {}
79 unsafe impl Sync for [u8; 16] {}
82 unsafe auto trait Freeze {}
84 unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
85 unsafe impl<T: ?Sized> Freeze for *const T {}
86 unsafe impl<T: ?Sized> Freeze for *mut T {}
87 unsafe impl<T: ?Sized> Freeze for &T {}
88 unsafe impl<T: ?Sized> Freeze for &mut T {}
90 #[lang = "structural_peq"]
91 pub trait StructuralPartialEq {}
93 #[lang = "structural_teq"]
94 pub trait StructuralEq {}
100 fn not(self) -> Self::Output;
106 fn not(self) -> bool {
112 pub trait Mul<RHS = Self> {
116 fn mul(self, rhs: RHS) -> Self::Output;
122 fn mul(self, rhs: Self) -> Self::Output {
130 fn mul(self, rhs: Self) -> Self::Output {
136 pub trait Add<RHS = Self> {
139 fn add(self, rhs: RHS) -> Self::Output;
145 fn add(self, rhs: Self) -> Self {
153 fn add(self, rhs: Self) -> Self {
161 fn add(self, rhs: Self) -> Self {
167 pub trait Sub<RHS = Self> {
170 fn sub(self, rhs: RHS) -> Self::Output;
176 fn sub(self, rhs: Self) -> Self {
184 fn sub(self, rhs: Self) -> Self {
192 fn sub(self, rhs: Self) -> Self {
200 fn sub(self, rhs: Self) -> Self {
206 pub trait Rem<RHS = Self> {
209 fn rem(self, rhs: RHS) -> Self::Output;
215 fn rem(self, rhs: Self) -> Self {
221 pub trait BitOr<RHS = Self> {
225 fn bitor(self, rhs: RHS) -> Self::Output;
228 impl BitOr for bool {
231 fn bitor(self, rhs: bool) -> bool {
236 impl<'a> BitOr<bool> for &'a bool {
239 fn bitor(self, rhs: bool) -> bool {
245 pub trait PartialEq<Rhs: ?Sized = Self> {
246 fn eq(&self, other: &Rhs) -> bool;
247 fn ne(&self, other: &Rhs) -> bool;
250 impl PartialEq for u8 {
251 fn eq(&self, other: &u8) -> bool {
254 fn ne(&self, other: &u8) -> bool {
259 impl PartialEq for u16 {
260 fn eq(&self, other: &u16) -> bool {
263 fn ne(&self, other: &u16) -> bool {
268 impl PartialEq for u32 {
269 fn eq(&self, other: &u32) -> bool {
272 fn ne(&self, other: &u32) -> bool {
278 impl PartialEq for u64 {
279 fn eq(&self, other: &u64) -> bool {
282 fn ne(&self, other: &u64) -> bool {
287 impl PartialEq for u128 {
288 fn eq(&self, other: &u128) -> bool {
291 fn ne(&self, other: &u128) -> bool {
296 impl PartialEq for usize {
297 fn eq(&self, other: &usize) -> bool {
300 fn ne(&self, other: &usize) -> bool {
305 impl PartialEq for i8 {
306 fn eq(&self, other: &i8) -> bool {
309 fn ne(&self, other: &i8) -> bool {
314 impl PartialEq for i32 {
315 fn eq(&self, other: &i32) -> bool {
318 fn ne(&self, other: &i32) -> bool {
323 impl PartialEq for isize {
324 fn eq(&self, other: &isize) -> bool {
327 fn ne(&self, other: &isize) -> bool {
332 impl PartialEq for char {
333 fn eq(&self, other: &char) -> bool {
336 fn ne(&self, other: &char) -> bool {
341 impl<T: ?Sized> PartialEq for *const T {
342 fn eq(&self, other: &*const T) -> bool {
345 fn ne(&self, other: &*const T) -> bool {
350 impl <T: PartialEq> PartialEq for Option<T> {
351 fn eq(&self, other: &Self) -> bool {
352 match (self, other) {
353 (Some(lhs), Some(rhs)) => *lhs == *rhs,
354 (None, None) => true,
359 fn ne(&self, other: &Self) -> bool {
360 match (self, other) {
361 (Some(lhs), Some(rhs)) => *lhs != *rhs,
362 (None, None) => false,
369 pub trait Shl<RHS = Self> {
373 fn shl(self, rhs: RHS) -> Self::Output;
379 fn shl(self, rhs: u128) -> u128 {
388 fn neg(self) -> Self::Output;
402 fn neg(self) -> i16 {
410 fn neg(self) -> isize {
418 fn neg(self) -> f32 {
430 #[lang = "phantom_data"]
431 pub struct PhantomData<T: ?Sized>;
435 pub trait FnOnce<Args> {
436 #[lang = "fn_once_output"]
439 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
444 pub trait FnMut<Args>: FnOnce<Args> {
445 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
450 pub fn panic(_msg: &str) -> ! {
452 libc::puts("Panicking\n\0" as *const str as *const i8);
457 #[lang = "panic_bounds_check"]
459 fn panic_bounds_check(index: usize, len: usize) -> ! {
461 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);
466 #[lang = "eh_personality"]
467 fn eh_personality() -> ! {
471 #[lang = "drop_in_place"]
472 #[allow(unconditional_recursion)]
473 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
474 // Code here does not matter - this is replaced by the
475 // real drop glue by the compiler.
476 drop_in_place(to_drop);
483 fn deref(&self) -> &Self::Target;
486 pub struct Unique<T: ?Sized> {
487 pub pointer: *const T,
488 pub _marker: PhantomData<T>,
491 impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
493 impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
495 #[lang = "owned_box"]
496 pub struct Box<T: ?Sized>(Unique<T>, ());
498 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
500 impl<T: ?Sized> Drop for Box<T> {
502 // drop is currently performed by compiler.
506 impl<T> Deref for Box<T> {
509 fn deref(&self) -> &Self::Target {
514 #[lang = "exchange_malloc"]
515 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
520 unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
521 libc::free(ptr.pointer as *mut u8);
529 #[lang = "manually_drop"]
531 pub struct ManuallyDrop<T: ?Sized> {
535 #[lang = "maybe_uninit"]
537 pub union MaybeUninit<T> {
539 pub value: ManuallyDrop<T>,
543 extern "rust-intrinsic" {
545 pub fn size_of<T>() -> usize;
546 pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
547 pub fn min_align_of<T>() -> usize;
548 pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
549 pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
550 pub fn transmute<T, U>(e: T) -> U;
551 pub fn ctlz_nonzero<T>(x: T) -> T;
552 pub fn needs_drop<T>() -> bool;
553 pub fn bitreverse<T>(x: T) -> T;
554 pub fn bswap<T>(x: T) -> T;
555 pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
560 #[cfg_attr(unix, link(name = "c"))]
561 #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
563 pub fn puts(s: *const i8) -> i32;
564 pub fn printf(format: *const i8, ...) -> i32;
565 pub fn malloc(size: usize) -> *mut u8;
566 pub fn free(ptr: *mut u8);
567 pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
568 pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
569 pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
574 pub trait Index<Idx: ?Sized> {
576 fn index(&self, index: Idx) -> &Self::Output;
579 impl<T> Index<usize> for [T; 3] {
582 fn index(&self, index: usize) -> &Self::Output {
587 impl<T> Index<usize> for [T] {
590 fn index(&self, index: usize) -> &Self::Output {
601 pub struct VaList<'a>(&'a mut VaListImpl);
603 #[rustc_builtin_macro]
604 #[rustc_macro_transparency = "semitransparent"]
605 pub macro stringify($($t:tt)*) { /* compiler built-in */ }
607 #[rustc_builtin_macro]
608 #[rustc_macro_transparency = "semitransparent"]
609 pub macro file() { /* compiler built-in */ }
611 #[rustc_builtin_macro]
612 #[rustc_macro_transparency = "semitransparent"]
613 pub macro line() { /* compiler built-in */ }
615 #[rustc_builtin_macro]
616 #[rustc_macro_transparency = "semitransparent"]
617 pub macro cfg() { /* compiler built-in */ }
619 #[rustc_builtin_macro]
620 #[rustc_macro_transparency = "semitransparent"]
621 pub macro global_asm() { /* compiler built-in */ }
623 pub static A_STATIC: u8 = 42;
625 #[lang = "panic_location"]
626 struct PanicLocation {
634 pub fn get_tls() -> u8 {