about summary refs log tree commit diff
path: root/src/libcore/tests
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-10-10 20:08:23 +0800
committerkennytm <kennytm@gmail.com>2017-10-10 22:44:02 +0800
commit9effa73286686b297856cc7d1b84f32ecfab94c8 (patch)
tree17adba78fe22f9491bfc8ff51065bc96bc522869 /src/libcore/tests
parentf2efa793f02e737c830256d32be39273f244fd51 (diff)
parent3fff2d95bf90514e66892ca9be666c35eeae9165 (diff)
Rollup merge of #45095 - bluss:discriminant-send-sync, r=alexcrichton
Ensure std::mem::Discriminant is Send + Sync

`PhantomData<*const T>` has the implication of Send / Syncness following
the *const T type, but the discriminant should always be Send and Sync.

Use `PhantomData<fn() -> T>` which has the same variance in T, but is Send + Sync
Diffstat (limited to 'src/libcore/tests')
-rw-r--r--src/libcore/tests/mem.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libcore/tests/mem.rs b/src/libcore/tests/mem.rs
index 86e59c736ba..f55a1c81463 100644
--- a/src/libcore/tests/mem.rs
+++ b/src/libcore/tests/mem.rs
@@ -121,3 +121,19 @@ fn test_transmute() {
     }
 }
 
+#[test]
+#[allow(dead_code)]
+fn test_discriminant_send_sync() {
+    enum Regular {
+        A,
+        B(i32)
+    }
+    enum NotSendSync {
+        A(*const i32)
+    }
+
+    fn is_send_sync<T: Send + Sync>() { }
+
+    is_send_sync::<Discriminant<Regular>>();
+    is_send_sync::<Discriminant<NotSendSync>>();
+}