From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- third_party/rust/libc/src/dox.rs | 134 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 third_party/rust/libc/src/dox.rs (limited to 'third_party/rust/libc/src/dox.rs') diff --git a/third_party/rust/libc/src/dox.rs b/third_party/rust/libc/src/dox.rs new file mode 100644 index 000000000..c7d3dc9c2 --- /dev/null +++ b/third_party/rust/libc/src/dox.rs @@ -0,0 +1,134 @@ +pub use self::imp::*; + +#[cfg(not(dox))] +mod imp { + pub use core::option::Option; + pub use core::clone::Clone; + pub use core::marker::Copy; + pub use core::mem; +} + +#[cfg(dox)] +mod imp { + pub enum Option { + Some(T), + None, + } + impl Copy for Option {} + impl Clone for Option { + fn clone(&self) -> Option { loop {} } + } + + pub trait Clone { + fn clone(&self) -> Self; + } + + #[lang = "copy"] + pub trait Copy {} + + #[lang = "sync"] + pub trait Sync {} + impl Sync for T {} + + #[lang = "sized"] + pub trait Sized {} + + macro_rules! each_int { + ($mac:ident) => ( + $mac!(u8); + $mac!(u16); + $mac!(u32); + $mac!(u64); + $mac!(usize); + $mac!(i8); + $mac!(i16); + $mac!(i32); + $mac!(i64); + $mac!(isize); + ) + } + + #[lang = "div"] + pub trait Div { + type Output; + fn div(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_div { + ($($i:ident)*) => ($( + impl Div<$i> for $i { + type Output = $i; + fn div(self, rhs: $i) -> $i { self / rhs } + } + )*) + } + each_int!(impl_div); + + #[lang = "shl"] + pub trait Shl { + type Output; + fn shl(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_shl { + ($($i:ident)*) => ($( + impl Shl<$i> for $i { + type Output = $i; + fn shl(self, rhs: $i) -> $i { self << rhs } + } + )*) + } + each_int!(impl_shl); + + #[lang = "mul"] + pub trait Mul { + type Output; + fn mul(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_mul { + ($($i:ident)*) => ($( + impl Mul for $i { + type Output = $i; + fn mul(self, rhs: $i) -> $i { self * rhs } + } + )*) + } + each_int!(impl_mul); + + #[lang = "sub"] + pub trait Sub { + type Output; + fn sub(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_sub { + ($($i:ident)*) => ($( + impl Sub for $i { + type Output = $i; + fn sub(self, rhs: $i) -> $i { self - rhs } + } + )*) + } + each_int!(impl_sub); + + #[lang = "bitor"] + pub trait Bitor { + type Output; + fn bitor(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_bitor { + ($($i:ident)*) => ($( + impl Bitor for $i { + type Output = $i; + fn bitor(self, rhs: $i) -> $i { self | rhs } + } + )*) + } + each_int!(impl_bitor); + + pub mod mem { + pub fn size_of_val(_: &T) -> usize { 4 } + } +} -- cgit v1.2.3