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 f64 {}
59 unsafe impl Copy for char {}
60 unsafe impl<'a, T: ?Sized> Copy for &'a T {}
61 unsafe impl<T: ?Sized> Copy for *const T {}
62 unsafe impl<T: ?Sized> Copy for *mut T {}
63 unsafe impl<T: Copy> Copy for Option<T> {}
66 pub unsafe trait Sync {}
68 unsafe impl Sync for bool {}
69 unsafe impl Sync for u8 {}
70 unsafe impl Sync for u16 {}
71 unsafe impl Sync for u32 {}
72 unsafe impl Sync for u64 {}
73 unsafe impl Sync for usize {}
74 unsafe impl Sync for i8 {}
75 unsafe impl Sync for i16 {}
76 unsafe impl Sync for i32 {}
77 unsafe impl Sync for isize {}
78 unsafe impl Sync for char {}
79 unsafe impl<'a, T: ?Sized> Sync for &'a T {}
80 unsafe impl Sync for [u8; 16] {}
83 unsafe auto trait Freeze {}
85 unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
86 unsafe impl<T: ?Sized> Freeze for *const T {}
87 unsafe impl<T: ?Sized> Freeze for *mut T {}
88 unsafe impl<T: ?Sized> Freeze for &T {}
89 unsafe impl<T: ?Sized> Freeze for &mut T {}
91 #[lang = "structural_peq"]
92 pub trait StructuralPartialEq {}
94 #[lang = "structural_teq"]
95 pub trait StructuralEq {}
101 fn not(self) -> Self::Output;
107 fn not(self) -> bool {
113 pub trait Mul<RHS = Self> {
117 fn mul(self, rhs: RHS) -> Self::Output;
123 fn mul(self, rhs: Self) -> Self::Output {
131 fn mul(self, rhs: Self) -> Self::Output {
137 pub trait Add<RHS = Self> {
140 fn add(self, rhs: RHS) -> Self::Output;
146 fn add(self, rhs: Self) -> Self {
154 fn add(self, rhs: Self) -> Self {
162 fn add(self, rhs: Self) -> Self {
168 pub trait Sub<RHS = Self> {
171 fn sub(self, rhs: RHS) -> Self::Output;
177 fn sub(self, rhs: Self) -> Self {
185 fn sub(self, rhs: Self) -> Self {
193 fn sub(self, rhs: Self) -> Self {
201 fn sub(self, rhs: Self) -> Self {
207 pub trait Rem<RHS = Self> {
210 fn rem(self, rhs: RHS) -> Self::Output;
216 fn rem(self, rhs: Self) -> Self {
222 pub trait BitOr<RHS = Self> {
226 fn bitor(self, rhs: RHS) -> Self::Output;
229 impl BitOr for bool {
232 fn bitor(self, rhs: bool) -> bool {
237 impl<'a> BitOr<bool> for &'a bool {
240 fn bitor(self, rhs: bool) -> bool {
246 pub trait PartialEq<Rhs: ?Sized = Self> {
247 fn eq(&self, other: &Rhs) -> bool;
248 fn ne(&self, other: &Rhs) -> bool;
251 impl PartialEq for u8 {
252 fn eq(&self, other: &u8) -> bool {
255 fn ne(&self, other: &u8) -> bool {
260 impl PartialEq for u16 {
261 fn eq(&self, other: &u16) -> bool {
264 fn ne(&self, other: &u16) -> bool {
269 impl PartialEq for u32 {
270 fn eq(&self, other: &u32) -> bool {
273 fn ne(&self, other: &u32) -> bool {
279 impl PartialEq for u64 {
280 fn eq(&self, other: &u64) -> bool {
283 fn ne(&self, other: &u64) -> bool {
288 impl PartialEq for u128 {
289 fn eq(&self, other: &u128) -> bool {
292 fn ne(&self, other: &u128) -> bool {
297 impl PartialEq for usize {
298 fn eq(&self, other: &usize) -> bool {
301 fn ne(&self, other: &usize) -> bool {
306 impl PartialEq for i8 {
307 fn eq(&self, other: &i8) -> bool {
310 fn ne(&self, other: &i8) -> bool {
315 impl PartialEq for i32 {
316 fn eq(&self, other: &i32) -> bool {
319 fn ne(&self, other: &i32) -> bool {
324 impl PartialEq for isize {
325 fn eq(&self, other: &isize) -> bool {
328 fn ne(&self, other: &isize) -> bool {
333 impl PartialEq for char {
334 fn eq(&self, other: &char) -> bool {
337 fn ne(&self, other: &char) -> bool {
342 impl<T: ?Sized> PartialEq for *const T {
343 fn eq(&self, other: &*const T) -> bool {
346 fn ne(&self, other: &*const T) -> bool {
351 impl <T: PartialEq> PartialEq for Option<T> {
352 fn eq(&self, other: &Self) -> bool {
353 match (self, other) {
354 (Some(lhs), Some(rhs)) => *lhs == *rhs,
355 (None, None) => true,
360 fn ne(&self, other: &Self) -> bool {
361 match (self, other) {
362 (Some(lhs), Some(rhs)) => *lhs != *rhs,
363 (None, None) => false,
370 pub trait Shl<RHS = Self> {
374 fn shl(self, rhs: RHS) -> Self::Output;
380 fn shl(self, rhs: u128) -> u128 {
389 fn neg(self) -> Self::Output;
403 fn neg(self) -> i16 {
411 fn neg(self) -> isize {
419 fn neg(self) -> f32 {
431 #[lang = "phantom_data"]
432 pub struct PhantomData<T: ?Sized>;
436 pub trait FnOnce<Args> {
437 #[lang = "fn_once_output"]
440 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
445 pub trait FnMut<Args>: FnOnce<Args> {
446 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
451 pub fn panic(_msg: &str) -> ! {
453 libc::puts("Panicking\n\0" as *const str as *const i8);
458 #[lang = "panic_bounds_check"]
460 fn panic_bounds_check(index: usize, len: usize) -> ! {
462 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);
467 #[lang = "eh_personality"]
468 fn eh_personality() -> ! {
472 #[lang = "drop_in_place"]
473 #[allow(unconditional_recursion)]
474 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
475 // Code here does not matter - this is replaced by the
476 // real drop glue by the compiler.
477 drop_in_place(to_drop);
484 fn deref(&self) -> &Self::Target;
487 pub struct Unique<T: ?Sized> {
488 pub pointer: *const T,
489 pub _marker: PhantomData<T>,
492 impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
494 impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
496 #[lang = "owned_box"]
497 pub struct Box<T: ?Sized>(Unique<T>, ());
499 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
501 impl<T: ?Sized> Drop for Box<T> {
503 // drop is currently performed by compiler.
507 impl<T> Deref for Box<T> {
510 fn deref(&self) -> &Self::Target {
515 #[lang = "exchange_malloc"]
516 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
521 unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
522 libc::free(ptr.pointer as *mut u8);
530 #[lang = "manually_drop"]
532 pub struct ManuallyDrop<T: ?Sized> {
536 #[lang = "maybe_uninit"]
538 pub union MaybeUninit<T> {
540 pub value: ManuallyDrop<T>,
544 extern "rust-intrinsic" {
546 pub fn size_of<T>() -> usize;
547 pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
548 pub fn min_align_of<T>() -> usize;
549 pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
550 pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
551 pub fn transmute<T, U>(e: T) -> U;
552 pub fn ctlz_nonzero<T>(x: T) -> T;
553 pub fn needs_drop<T>() -> bool;
554 pub fn bitreverse<T>(x: T) -> T;
555 pub fn bswap<T>(x: T) -> T;
556 pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
561 #[cfg_attr(unix, link(name = "c"))]
562 #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
564 pub fn puts(s: *const i8) -> i32;
565 pub fn printf(format: *const i8, ...) -> i32;
566 pub fn malloc(size: usize) -> *mut u8;
567 pub fn free(ptr: *mut u8);
568 pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
569 pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
570 pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
575 pub trait Index<Idx: ?Sized> {
577 fn index(&self, index: Idx) -> &Self::Output;
580 impl<T> Index<usize> for [T; 3] {
583 fn index(&self, index: usize) -> &Self::Output {
588 impl<T> Index<usize> for [T] {
591 fn index(&self, index: usize) -> &Self::Output {
602 pub struct VaList<'a>(&'a mut VaListImpl);
604 #[rustc_builtin_macro]
605 #[rustc_macro_transparency = "semitransparent"]
606 pub macro stringify($($t:tt)*) { /* compiler built-in */ }
608 #[rustc_builtin_macro]
609 #[rustc_macro_transparency = "semitransparent"]
610 pub macro file() { /* compiler built-in */ }
612 #[rustc_builtin_macro]
613 #[rustc_macro_transparency = "semitransparent"]
614 pub macro line() { /* compiler built-in */ }
616 #[rustc_builtin_macro]
617 #[rustc_macro_transparency = "semitransparent"]
618 pub macro cfg() { /* compiler built-in */ }
620 #[rustc_builtin_macro]
621 #[rustc_macro_transparency = "semitransparent"]
622 pub macro global_asm() { /* compiler built-in */ }
624 pub static A_STATIC: u8 = 42;
626 #[lang = "panic_location"]
627 struct PanicLocation {
635 pub fn get_tls() -> u8 {