]> git.lizzy.rs Git - rust.git/blob - src/test/ui/thread-local/thread-local-issue-37508.rs
Rollup merge of #102092 - kxxt:patch-1, r=joshtriplett
[rust.git] / src / test / ui / thread-local / thread-local-issue-37508.rs
1 // only-x86_64
2 // compile-flags: -Ccode-model=large --crate-type lib
3 // build-pass
4 //
5 // Regression test for issue #37508
6
7 #![no_main]
8 #![no_std]
9 #![feature(thread_local, lang_items)]
10
11 #[lang = "eh_personality"]
12 extern "C" fn eh_personality() {}
13
14 use core::panic::PanicInfo;
15
16 #[panic_handler]
17 fn panic(_panic: &PanicInfo<'_>) -> ! {
18     loop {}
19 }
20
21 pub struct BB;
22
23 #[thread_local]
24 static mut KEY: Key = Key { inner: BB, dtor_running: false };
25
26 pub unsafe fn set() -> Option<&'static BB> {
27     if KEY.dtor_running {
28         return None;
29     }
30     Some(&KEY.inner)
31 }
32
33 pub struct Key {
34     inner: BB,
35     dtor_running: bool,
36 }