Skip to content

Commit b18d55b

Browse files
committed
Add test for main thread thread-local destructors
1 parent a747617 commit b18d55b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//! Ensure that TLS destructors run on the main thread.
2+
//@ run-pass
3+
//@ check-run-results
4+
5+
struct Bar;
6+
7+
impl Drop for Bar {
8+
fn drop(&mut self) {
9+
println!("Bar dtor");
10+
}
11+
}
12+
13+
struct Foo;
14+
15+
impl Drop for Foo {
16+
fn drop(&mut self) {
17+
println!("Foo dtor");
18+
// We initialize another thread-local inside the dtor, which is an interesting corner case.
19+
thread_local!(static BAR: Bar = Bar);
20+
BAR.with(|_| {});
21+
}
22+
}
23+
24+
thread_local!(static FOO: Foo = Foo);
25+
26+
fn main() {
27+
FOO.with(|_| {});
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Foo dtor
2+
Bar dtor

0 commit comments

Comments
 (0)