2018-07-20 06:38:49 -05:00
|
|
|
#![feature(no_core, lang_items, intrinsics, unboxed_closures)]
|
2018-07-24 07:10:53 -05:00
|
|
|
#![no_core]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2018-07-31 05:25:16 -05:00
|
|
|
#[lang = "sized"]
|
2018-07-24 07:10:53 -05:00
|
|
|
pub trait Sized {}
|
|
|
|
|
2018-07-30 10:29:39 -05:00
|
|
|
#[lang = "unsize"]
|
|
|
|
pub trait Unsize<T: ?Sized> {}
|
|
|
|
|
|
|
|
#[lang = "coerce_unsized"]
|
|
|
|
pub trait CoerceUnsized<T> {}
|
|
|
|
|
2018-07-31 05:25:16 -05:00
|
|
|
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
|
2018-07-30 10:29:39 -05:00
|
|
|
|
2018-07-31 05:25:16 -05:00
|
|
|
#[lang = "copy"]
|
2018-07-24 07:10:53 -05:00
|
|
|
pub unsafe trait Copy {}
|
|
|
|
|
2018-07-26 03:59:57 -05:00
|
|
|
unsafe impl Copy for bool {}
|
2018-07-24 07:10:53 -05:00
|
|
|
unsafe impl Copy for u8 {}
|
|
|
|
unsafe impl Copy for u16 {}
|
|
|
|
unsafe impl Copy for u32 {}
|
|
|
|
unsafe impl Copy for u64 {}
|
|
|
|
unsafe impl Copy for usize {}
|
|
|
|
unsafe impl Copy for i8 {}
|
|
|
|
unsafe impl Copy for i16 {}
|
|
|
|
unsafe impl Copy for i32 {}
|
|
|
|
unsafe impl Copy for isize {}
|
2018-07-26 03:48:50 -05:00
|
|
|
unsafe impl Copy for char {}
|
2018-07-24 07:10:53 -05:00
|
|
|
unsafe impl<'a, T: ?Sized> Copy for &'a T {}
|
|
|
|
unsafe impl<T: ?Sized> Copy for *const T {}
|
|
|
|
|
2018-08-09 04:41:34 -05:00
|
|
|
#[lang = "sync"]
|
|
|
|
pub unsafe trait Sync {}
|
|
|
|
|
|
|
|
unsafe impl Sync for bool {}
|
|
|
|
unsafe impl Sync for u8 {}
|
|
|
|
unsafe impl Sync for u16 {}
|
|
|
|
unsafe impl Sync for u32 {}
|
|
|
|
unsafe impl Sync for u64 {}
|
|
|
|
unsafe impl Sync for usize {}
|
|
|
|
unsafe impl Sync for i8 {}
|
|
|
|
unsafe impl Sync for i16 {}
|
|
|
|
unsafe impl Sync for i32 {}
|
|
|
|
unsafe impl Sync for isize {}
|
|
|
|
unsafe impl Sync for char {}
|
2018-08-13 12:02:42 -05:00
|
|
|
unsafe impl<'a, T: ?Sized> Sync for &'a T {}
|
2018-08-09 04:41:34 -05:00
|
|
|
|
2018-07-31 05:25:16 -05:00
|
|
|
#[lang = "freeze"]
|
2018-07-24 07:10:53 -05:00
|
|
|
trait Freeze {}
|
|
|
|
|
2018-07-31 05:25:16 -05:00
|
|
|
#[lang = "mul"]
|
2018-07-24 07:10:53 -05:00
|
|
|
pub trait Mul<RHS = Self> {
|
|
|
|
type Output;
|
|
|
|
|
|
|
|
#[must_use]
|
|
|
|
fn mul(self, rhs: RHS) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Mul for u8 {
|
|
|
|
type Output = Self;
|
|
|
|
|
2018-08-13 08:56:01 -05:00
|
|
|
fn mul(self, rhs: Self) -> Self::Output {
|
2018-07-24 07:10:53 -05:00
|
|
|
self * rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-13 12:14:55 -05:00
|
|
|
#[lang = "add"]
|
|
|
|
pub trait Add<RHS = Self> {
|
|
|
|
type Output;
|
|
|
|
|
|
|
|
fn add(self, rhs: RHS) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Add for u8 {
|
|
|
|
type Output = Self;
|
|
|
|
|
|
|
|
fn add(self, rhs: Self) -> Self {
|
|
|
|
self + rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-13 08:56:01 -05:00
|
|
|
#[lang = "sub"]
|
|
|
|
pub trait Sub<RHS = Self> {
|
|
|
|
type Output;
|
|
|
|
|
|
|
|
fn sub(self, rhs: RHS) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Sub for usize {
|
|
|
|
type Output = Self;
|
|
|
|
|
|
|
|
fn sub(self, rhs: Self) -> Self {
|
|
|
|
self - rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-31 05:25:16 -05:00
|
|
|
#[lang = "bitor"]
|
2018-07-26 03:59:57 -05:00
|
|
|
pub trait BitOr<RHS = Self> {
|
|
|
|
type Output;
|
|
|
|
|
|
|
|
#[must_use]
|
|
|
|
fn bitor(self, rhs: RHS) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BitOr for bool {
|
|
|
|
type Output = bool;
|
|
|
|
|
|
|
|
fn bitor(self, rhs: bool) -> bool {
|
|
|
|
self | rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> BitOr<bool> for &'a bool {
|
|
|
|
type Output = bool;
|
|
|
|
|
|
|
|
fn bitor(self, rhs: bool) -> bool {
|
|
|
|
*self | rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-24 07:10:53 -05:00
|
|
|
#[lang = "eq"]
|
|
|
|
pub trait PartialEq<Rhs: ?Sized = Self> {
|
|
|
|
fn eq(&self, other: &Rhs) -> bool;
|
|
|
|
fn ne(&self, other: &Rhs) -> bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialEq for u8 {
|
2018-07-31 05:25:16 -05:00
|
|
|
fn eq(&self, other: &u8) -> bool {
|
|
|
|
(*self) == (*other)
|
|
|
|
}
|
|
|
|
fn ne(&self, other: &u8) -> bool {
|
|
|
|
(*self) != (*other)
|
|
|
|
}
|
2018-07-24 07:10:53 -05:00
|
|
|
}
|
|
|
|
|
2018-07-26 03:48:50 -05:00
|
|
|
impl PartialEq for char {
|
2018-07-31 05:25:16 -05:00
|
|
|
fn eq(&self, other: &char) -> bool {
|
|
|
|
(*self) == (*other)
|
|
|
|
}
|
|
|
|
fn ne(&self, other: &char) -> bool {
|
|
|
|
(*self) != (*other)
|
|
|
|
}
|
2018-07-26 03:48:50 -05:00
|
|
|
}
|
|
|
|
|
2018-07-24 07:10:53 -05:00
|
|
|
impl<T: ?Sized> PartialEq for *const T {
|
2018-07-31 05:25:16 -05:00
|
|
|
fn eq(&self, other: &*const T) -> bool {
|
|
|
|
*self == *other
|
|
|
|
}
|
|
|
|
fn ne(&self, other: &*const T) -> bool {
|
|
|
|
*self != *other
|
|
|
|
}
|
2018-07-24 07:10:53 -05:00
|
|
|
}
|
|
|
|
|
2018-07-20 06:38:49 -05:00
|
|
|
#[lang = "fn_once"]
|
|
|
|
#[rustc_paren_sugar]
|
2018-07-27 12:27:20 -05:00
|
|
|
pub trait FnOnce<Args> {
|
2018-07-20 06:38:49 -05:00
|
|
|
type Output;
|
|
|
|
|
|
|
|
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "fn_mut"]
|
|
|
|
#[rustc_paren_sugar]
|
2018-07-31 05:25:16 -05:00
|
|
|
pub trait FnMut<Args>: FnOnce<Args> {
|
2018-07-20 06:38:49 -05:00
|
|
|
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
2018-07-31 05:25:16 -05:00
|
|
|
#[lang = "panic"]
|
2018-07-24 07:10:53 -05:00
|
|
|
pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2018-08-11 07:52:00 -05:00
|
|
|
#[lang = "eh_personality"]
|
|
|
|
fn eh_personality() -> ! {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2018-07-24 07:10:53 -05:00
|
|
|
#[lang = "drop_in_place"]
|
|
|
|
#[allow(unconditional_recursion)]
|
|
|
|
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
|
|
|
|
// Code here does not matter - this is replaced by the
|
|
|
|
// real drop glue by the compiler.
|
|
|
|
drop_in_place(to_drop);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod intrinsics {
|
|
|
|
extern "rust-intrinsic" {
|
|
|
|
pub fn size_of<T>() -> usize;
|
|
|
|
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
|
2018-07-26 03:48:50 -05:00
|
|
|
pub fn transmute<T, U>(e: T) -> U;
|
2018-07-29 10:22:40 -05:00
|
|
|
pub fn uninit<T>() -> T;
|
2018-08-08 07:39:46 -05:00
|
|
|
pub fn ctlz_nonzero<T>(x: T) -> T;
|
2018-07-24 07:10:53 -05:00
|
|
|
}
|
|
|
|
}
|
2018-08-08 05:22:16 -05:00
|
|
|
|
|
|
|
#[lang = "index"]
|
|
|
|
pub trait Index<Idx: ?Sized> {
|
|
|
|
type Output: ?Sized;
|
|
|
|
fn index(&self, index: Idx) -> &Self::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Index<usize> for [T; 3] {
|
|
|
|
type Output = T;
|
|
|
|
|
|
|
|
fn index(&self, index: usize) -> &Self::Output {
|
|
|
|
&self[index]
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 04:22:48 -05:00
|
|
|
|
|
|
|
impl<T> Index<usize> for [T] {
|
|
|
|
type Output = T;
|
|
|
|
|
|
|
|
fn index(&self, index: usize) -> &Self::Output {
|
|
|
|
&self[index]
|
|
|
|
}
|
|
|
|
}
|