diff --git a/src/context.rs b/src/context.rs index 350879fdb204c4face3271a417b34840cd7134c7..29bc53b2c228b3aef074ec18ce663074e0527f32 100644 --- a/src/context.rs +++ b/src/context.rs @@ -11,7 +11,7 @@ use std::collections::HashMap; /// This context is used by default and you don't need to create it manually. #[doc(hidden)] pub struct GlobalContext { - _not_thread_safe: UnsafeCell<()>, + _not_thread_safe: UnsafeCell<YouMustUseThreadContextToShareBetweenThreads>, } #[doc(hidden)] @@ -33,6 +33,9 @@ impl Context for GlobalContext { } } +#[doc(hidden)] +struct YouMustUseThreadContextToShareBetweenThreads; + unsafe impl Send for ThreadContext {} impl<'a> Context for &'a ThreadContext { @@ -70,7 +73,7 @@ pub struct ThreadContext { impl GlobalContext { pub fn new() -> Self { Self { - _not_thread_safe: UnsafeCell::new(()), + _not_thread_safe: UnsafeCell::new(YouMustUseThreadContextToShareBetweenThreads), } }