diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2022-04-06 13:50:45 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2022-04-12 08:44:38 +0200 |
| commit | ebebe6f837b3499efb5cf1eb95e7eeffbc5e477a (patch) | |
| tree | 9d3314c66d2c26c02ec26f1a1ef84556a782add1 /library/std/src | |
| parent | bd61bec67d23e11a37a19a3a554753419c734947 (diff) | |
| download | rust-ebebe6f837b3499efb5cf1eb95e7eeffbc5e477a.tar.gz rust-ebebe6f837b3499efb5cf1eb95e7eeffbc5e477a.zip | |
Make current_thread_unique_ptr work during thread destruction.
Otherwise we can't use println!() within atexit handlers etc.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys_common/thread_info.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/library/std/src/sys_common/thread_info.rs b/library/std/src/sys_common/thread_info.rs index cd570dca0ff..b8f2e658214 100644 --- a/library/std/src/sys_common/thread_info.rs +++ b/library/std/src/sys_common/thread_info.rs @@ -34,7 +34,9 @@ impl ThreadInfo { /// /// This can be used as a non-null usize-sized ID. pub fn current_thread_unique_ptr() -> usize { - THREAD_INFO.with(|info| <*const _>::addr(info)) + // Use a non-drop type to make sure it's still available during thread destruction. + thread_local! { static X: u8 = 0 } + X.with(|x| <*const _>::addr(x)) } pub fn current_thread() -> Option<Thread> { |
