about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorJames Miller <james@aatch.net>2015-01-11 12:58:20 +1300
committerFelix S. Klock II <pnkfelix@pnkfx.org>2015-04-10 12:23:08 +0200
commit41dd35503a358b652cfbbf7fba499cbaf1234637 (patch)
tree02479899a1c7e3fa021bf26cf22fe8636c4b323d /src/libcore
parent6b95d8bed8afff7262ec5623677e320bf63d2230 (diff)
downloadrust-41dd35503a358b652cfbbf7fba499cbaf1234637.tar.gz
rust-41dd35503a358b652cfbbf7fba499cbaf1234637.zip
Implement `discriminant_value` intrinsic
Implements an intrinsic for extracting the value of the discriminant
enum variant values. For non-enum types, this returns zero, otherwise it
returns the value we use for discriminant comparisons. This means that
enum types that do not have a discriminant will also work in this
arrangement.

This is (at least part of) the work on Issue #24263
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/intrinsics.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 0e91eafce18..80f506ebc06 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -569,4 +569,10 @@ extern "rust-intrinsic" {
     pub fn overflowing_sub<T>(a: T, b: T) -> T;
     /// Returns (a * b) mod 2^N, where N is the width of N in bits.
     pub fn overflowing_mul<T>(a: T, b: T) -> T;
+
+    /// Returns the value of the discriminant for the variant in 'v',
+    /// cast to a `u64`; if `T` has no discriminant, returns 0.
+    // SNAP 5520801
+    #[cfg(not(stage0))]
+    pub fn discriminant_value<T>(v: &T) -> u64;
 }