about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/std/src/thread/local.rs6
-rw-r--r--src/test/ui/thread-local/name-collision.rs15
2 files changed, 18 insertions, 3 deletions
diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs
index 587e453ceef..a41cb02a607 100644
--- a/library/std/src/thread/local.rs
+++ b/library/std/src/thread/local.rs
@@ -217,9 +217,9 @@ macro_rules! __thread_local_inner {
                 // 1 == dtor registered, dtor not run
                 // 2 == dtor registered and is running or has run
                 #[thread_local]
-                static mut STATE: u8 = 0;
+                static mut STATE: $crate::primitive::u8 = 0;
 
-                unsafe extern "C" fn destroy(ptr: *mut u8) {
+                unsafe extern "C" fn destroy(ptr: *mut $crate::primitive::u8) {
                     let ptr = ptr as *mut $t;
 
                     unsafe {
@@ -235,7 +235,7 @@ macro_rules! __thread_local_inner {
                         //   so now.
                         0 => {
                             $crate::thread::__FastLocalKeyInner::<$t>::register_dtor(
-                                $crate::ptr::addr_of_mut!(VAL) as *mut u8,
+                                $crate::ptr::addr_of_mut!(VAL) as *mut $crate::primitive::u8,
                                 destroy,
                             );
                             STATE = 1;
diff --git a/src/test/ui/thread-local/name-collision.rs b/src/test/ui/thread-local/name-collision.rs
new file mode 100644
index 00000000000..dcff9183ad9
--- /dev/null
+++ b/src/test/ui/thread-local/name-collision.rs
@@ -0,0 +1,15 @@
+// check-pass
+
+#[allow(non_camel_case_types)]
+struct u8;
+
+std::thread_local! {
+    pub static A: i32 = f();
+    pub static B: i32 = const { 0 };
+}
+
+fn f() -> i32 {
+    0
+}
+
+fn main() {}