]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/unstable/intrinsics.rs
Register new snapshots
[rust.git] / src / libstd / unstable / intrinsics.rs
index ea3ed10da4ed0716d7c3e78cdd4e87959363f15a..d3649f0285caa221c98dac1df5faef36c395e537 100644 (file)
@@ -34,7 +34,7 @@
 
 // This is needed to prevent duplicate lang item definitions.
 #[cfg(test)]
-pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor};
+pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
 
 pub type GlueFn = extern "Rust" fn(*i8);
 
@@ -177,7 +177,6 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
     pub fn abort() -> !;
 
     /// Execute a breakpoint trap, for inspection by a debugger.
-    #[cfg(not(stage0))]
     pub fn breakpoint();
 
     /// Atomic compare and exchange, sequentially consistent.
@@ -314,7 +313,8 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
     /// 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.
-    pub fn type_id<T: 'static>() -> u64;
+    pub fn type_id<T: 'static>() -> TypeId;
+
 
     /// Create a value initialized to zero.
     ///
@@ -487,3 +487,21 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
 #[cfg(target_endian = "big")]    pub fn to_be32(x: i32) -> i32 { x }
 #[cfg(target_endian = "little")] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
 #[cfg(target_endian = "big")]    pub fn to_be64(x: i64) -> i64 { x }
+
+
+/// `TypeId` represents a globally unique identifier for a type
+#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
+                  // middle/lang_items.rs
+#[deriving(Eq, IterBytes)]
+#[cfg(not(test))]
+pub struct TypeId {
+    priv t: u64,
+}
+
+#[cfg(not(test))]
+impl TypeId {
+    /// Returns the `TypeId` of the type this generic function has been instantiated with
+    pub fn of<T: 'static>() -> TypeId {
+        unsafe { type_id::<T>() }
+    }
+}