File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ //! Ensure that TLS destructors run on the main thread.
2
+ //@ run-pass
3
+ //@ check-run-results
4
+ // targets without threads tend to implement thread-locals as `static`s so no dtors are running
5
+ //@ needs-threads
6
+ // some targets do not run dtors on the main thread (issue #126858)
7
+ //@ ignore-musl
8
+ //@ ignore-android
9
+
10
+ struct Bar ;
11
+
12
+ impl Drop for Bar {
13
+ fn drop ( & mut self ) {
14
+ println ! ( "Bar dtor" ) ;
15
+ }
16
+ }
17
+
18
+ struct Foo ;
19
+
20
+ impl Drop for Foo {
21
+ fn drop ( & mut self ) {
22
+ println ! ( "Foo dtor" ) ;
23
+ // We initialize another thread-local inside the dtor, which is an interesting corner case.
24
+ thread_local ! ( static BAR : Bar = Bar ) ;
25
+ BAR . with ( |_| { } ) ;
26
+ }
27
+ }
28
+
29
+ thread_local ! ( static FOO : Foo = Foo ) ;
30
+
31
+ fn main ( ) {
32
+ FOO . with ( |_| { } ) ;
33
+ }
Original file line number Diff line number Diff line change
1
+ Foo dtor
2
+ Bar dtor
You can’t perform that action at this time.
0 commit comments