2 no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
3 untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_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,
372 fn neg(self) -> Self::Output;
386 fn neg(self) -> i16 {
394 fn neg(self) -> isize {
402 fn neg(self) -> f32 {
414 #[lang = "phantom_data"]
415 pub struct PhantomData<T: ?Sized>;
419 pub trait FnOnce<Args> {
420 #[lang = "fn_once_output"]
423 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
428 pub trait FnMut<Args>: FnOnce<Args> {
429 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
434 pub fn panic(_msg: &str) -> ! {
436 libc::puts("Panicking\n\0" as *const str as *const i8);
441 #[lang = "panic_bounds_check"]
443 fn panic_bounds_check(index: usize, len: usize) -> ! {
445 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);
450 #[lang = "eh_personality"]
451 fn eh_personality() -> ! {
455 #[lang = "drop_in_place"]
456 #[allow(unconditional_recursion)]
457 pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
458 // Code here does not matter - this is replaced by the
459 // real drop glue by the compiler.
460 drop_in_place(to_drop);
467 fn deref(&self) -> &Self::Target;
470 #[lang = "owned_box"]
471 pub struct Box<T: ?Sized>(*mut T);
473 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
475 impl<T: ?Sized> Drop for Box<T> {
477 // drop is currently performed by compiler.
481 impl<T> Deref for Box<T> {
484 fn deref(&self) -> &Self::Target {
489 #[lang = "exchange_malloc"]
490 unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
495 unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
496 libc::free(ptr as *mut u8);
504 #[lang = "manually_drop"]
506 pub struct ManuallyDrop<T: ?Sized> {
510 #[lang = "maybe_uninit"]
512 pub union MaybeUninit<T> {
514 pub value: ManuallyDrop<T>,
518 extern "rust-intrinsic" {
520 pub fn size_of<T>() -> usize;
521 pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
522 pub fn min_align_of<T>() -> usize;
523 pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
524 pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
525 pub fn transmute<T, U>(e: T) -> U;
526 pub fn ctlz_nonzero<T>(x: T) -> T;
527 pub fn needs_drop<T>() -> bool;
528 pub fn bitreverse<T>(x: T) -> T;
529 pub fn bswap<T>(x: T) -> T;
530 pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
535 #[cfg_attr(not(windows), link(name = "c"))]
536 #[cfg_attr(windows, link(name = "msvcrt"))]
538 pub fn puts(s: *const i8) -> i32;
539 pub fn printf(format: *const i8, ...) -> i32;
540 pub fn malloc(size: usize) -> *mut u8;
541 pub fn free(ptr: *mut u8);
542 pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
543 pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
544 pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
549 pub trait Index<Idx: ?Sized> {
551 fn index(&self, index: Idx) -> &Self::Output;
554 impl<T> Index<usize> for [T; 3] {
557 fn index(&self, index: usize) -> &Self::Output {
562 impl<T> Index<usize> for [T] {
565 fn index(&self, index: usize) -> &Self::Output {
576 pub struct VaList<'a>(&'a mut VaListImpl);
578 #[rustc_builtin_macro]
579 #[rustc_macro_transparency = "semitransparent"]
580 pub macro stringify($($t:tt)*) { /* compiler built-in */ }
582 #[rustc_builtin_macro]
583 #[rustc_macro_transparency = "semitransparent"]
584 pub macro file() { /* compiler built-in */ }
586 #[rustc_builtin_macro]
587 #[rustc_macro_transparency = "semitransparent"]
588 pub macro line() { /* compiler built-in */ }
590 #[rustc_builtin_macro]
591 #[rustc_macro_transparency = "semitransparent"]
592 pub macro cfg() { /* compiler built-in */ }
594 #[rustc_builtin_macro]
595 #[rustc_macro_transparency = "semitransparent"]
596 pub macro global_asm() { /* compiler built-in */ }
598 pub static A_STATIC: u8 = 42;
600 #[lang = "panic_location"]
601 struct PanicLocation {
608 pub fn get_tls() -> u8 {