From cbd647f122c4373e19d710fab6abe6bd5f2f3221 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Sat, 24 Apr 2021 10:33:23 +0100 Subject: [PATCH] Add test for issue #37508 --- src/test/ui/thread-local-issue-37508.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/ui/thread-local-issue-37508.rs diff --git a/src/test/ui/thread-local-issue-37508.rs b/src/test/ui/thread-local-issue-37508.rs new file mode 100644 index 0000000000000..87e4601c3c88a --- /dev/null +++ b/src/test/ui/thread-local-issue-37508.rs @@ -0,0 +1,22 @@ +// compile-flags: --crate-type rlib -C opt-level=3 -C code-model=large +// build-pass + +#![no_std] +#![feature(thread_local)] + +pub struct BB; + +#[thread_local] +static mut KEY: Key = Key { inner: BB, dtor_running: false }; + +pub unsafe fn set() -> Option<&'static BB> { + if KEY.dtor_running { + return None; + } + Some(&KEY.inner) +} + +pub struct Key { + inner: BB, + dtor_running: bool, +}