From 2862ad029a27b3b40f6624bf49c39752f22617fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= <kornel@geekhood.net>
Date: Wed, 10 Jul 2019 16:56:19 +0100
Subject: [PATCH] Use verbose type name for better thread-safety error mesage

---
 src/context.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/context.rs b/src/context.rs
index 350879f..29bc53b 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),
         }
     }
 
-- 
GitLab