diff options
| author | kennytm <kennytm@gmail.com> | 2017-10-10 20:08:23 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2017-10-10 22:44:02 +0800 |
| commit | 9effa73286686b297856cc7d1b84f32ecfab94c8 (patch) | |
| tree | 17adba78fe22f9491bfc8ff51065bc96bc522869 /src/libcore/tests | |
| parent | f2efa793f02e737c830256d32be39273f244fd51 (diff) | |
| parent | 3fff2d95bf90514e66892ca9be666c35eeae9165 (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.rs | 16 |
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>>(); +} |
