diff options
| author | Yerkebulan Tulibergenov <yerkebulan@gmail.com> | 2021-06-16 18:44:26 -0700 |
|---|---|---|
| committer | Yerkebulan Tulibergenov <yerkebulan@gmail.com> | 2021-06-16 18:44:26 -0700 |
| commit | a89c7e1f612a9189b4d3cf8cb8630fddc0b60fc6 (patch) | |
| tree | c1eaff6015df1cea0a279a21455b68c748b22461 | |
| parent | 0a8629bff642c3c3b84bb644c0099194f063b627 (diff) | |
| download | rust-a89c7e1f612a9189b4d3cf8cb8630fddc0b60fc6.tar.gz rust-a89c7e1f612a9189b4d3cf8cb8630fddc0b60fc6.zip | |
add regression test for issue #37508
| -rw-r--r-- | src/test/ui/thread-local/thread-local-issue-37508.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/thread-local/thread-local-issue-37508.rs b/src/test/ui/thread-local/thread-local-issue-37508.rs new file mode 100644 index 00000000000..219108c77f7 --- /dev/null +++ b/src/test/ui/thread-local/thread-local-issue-37508.rs @@ -0,0 +1,36 @@ +// only-x86_64 +// compile-flags: -Ccode-model=large --crate-type lib +// build-pass +// +// Regression test for issue #37508 + +#![no_main] +#![no_std] +#![feature(thread_local, lang_items)] + +#[lang = "eh_personality"] +extern "C" fn eh_personality() {} + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(_panic: &PanicInfo<'_>) -> ! { + loop {} +} + +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, +} |
