diff options
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/intrinsics.rs | 17 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 10 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index fe9100e8a5c..24ebd1ac21a 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -42,6 +42,9 @@ #![experimental] #![allow(missing_docs)] +#[cfg(not(stage0))] +use marker::Sized; + pub type GlueFn = extern "Rust" fn(*const i8); #[lang="ty_desc"] @@ -200,7 +203,10 @@ extern "rust-intrinsic" { /// Gets an identifier which is globally unique to the specified type. This /// function will return the same value for a type regardless of whichever /// crate it is invoked in. + #[cfg(not(stage0))] pub fn type_id<T: ?Sized + 'static>() -> TypeId; + #[cfg(stage0)] + pub fn type_id<T: 'static>() -> TypeId; /// Create a value initialized to zero. /// @@ -550,7 +556,16 @@ pub struct TypeId { } impl TypeId { - /// Returns the `TypeId` of the type this generic function has been instantiated with + /// Returns the `TypeId` of the type this generic function has been + /// instantiated with + #[cfg(stage0)] + pub fn of<T: 'static>() -> TypeId { + unsafe { type_id::<T>() } + } + + /// Returns the `TypeId` of the type this generic function has been + /// instantiated with + #[cfg(not(stage0))] pub fn of<T: ?Sized + 'static>() -> TypeId { unsafe { type_id::<T>() } } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 7fb08ceb610..bf2df465370 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -733,7 +733,7 @@ macro_rules! iterator { } macro_rules! make_slice { - ($t: ty -> $result: ty: $start: expr, $end: expr) => {{ + ($t: ty => $result: ty: $start: expr, $end: expr) => {{ let diff = $end as uint - $start as uint; let len = if mem::size_of::<T>() == 0 { diff @@ -797,7 +797,7 @@ impl<'a, T> Iter<'a, T> { /// iterator can continue to be used while this exists. #[experimental] pub fn as_slice(&self) -> &'a [T] { - make_slice!(T -> &'a [T]: self.ptr, self.end) + make_slice!(T => &'a [T]: self.ptr, self.end) } } @@ -876,7 +876,7 @@ impl<'a, T> ops::Index<ops::FullRange> for IterMut<'a, T> { type Output = [T]; #[inline] fn index(&self, _index: &ops::FullRange) -> &[T] { - make_slice!(T -> &[T]: self.ptr, self.end) + make_slice!(T => &[T]: self.ptr, self.end) } } @@ -909,7 +909,7 @@ impl<'a, T> ops::IndexMut<ops::FullRange> for IterMut<'a, T> { type Output = [T]; #[inline] fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] { - make_slice!(T -> &mut [T]: self.ptr, self.end) + make_slice!(T => &mut [T]: self.ptr, self.end) } } @@ -923,7 +923,7 @@ impl<'a, T> IterMut<'a, T> { /// restricted lifetimes that do not consume the iterator. #[experimental] pub fn into_slice(self) -> &'a mut [T] { - make_slice!(T -> &'a mut [T]: self.ptr, self.end) + make_slice!(T => &'a mut [T]: self.ptr, self.end) } } |
