From 3fff2d95bf90514e66892ca9be666c35eeae9165 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sat, 7 Oct 2017 21:33:36 +0200 Subject: core: 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 T>` which has the same variance in T, but is Send + Sync --- src/libcore/tests/mem.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/libcore/tests') 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() { } + + is_send_sync::>(); + is_send_sync::>(); +} -- cgit 1.4.1-3-g733a5