Check that nested statics in thread locals are duplicated per thread.
This commit is contained in:
parent
e2cf2cb303
commit
6c5c48e880
24
tests/ui/statics/nested_thread_local.rs
Normal file
24
tests/ui/statics/nested_thread_local.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// Check that nested statics in thread locals are
|
||||
// duplicated per thread.
|
||||
|
||||
#![feature(const_refs_to_cell)]
|
||||
#![feature(thread_local)]
|
||||
|
||||
//@run-pass
|
||||
|
||||
#[thread_local]
|
||||
static mut FOO: &mut u32 = &mut 42;
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
*FOO = 1;
|
||||
|
||||
let _ = std::thread::spawn(|| {
|
||||
assert_eq!(*FOO, 42);
|
||||
*FOO = 99;
|
||||
})
|
||||
.join();
|
||||
|
||||
assert_eq!(*FOO, 1);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user