Skip to content

Commit 1cccf5b

Browse files
committed
remember the main thread ID before performing platform initialisation
1 parent 5009847 commit 1cccf5b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/std/src/rt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ fn handle_rt_panic<T>(e: Box<dyn Any + Send>) -> T {
109109
// `compiler/rustc_session/src/config/sigpipe.rs`.
110110
#[cfg_attr(test, allow(dead_code))]
111111
unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
112+
// Remember the main thread ID to give it the correct name.
113+
// SAFETY: this is the only time and place where we call this function.
114+
unsafe { main_thread::set(thread::current_id()) };
115+
112116
#[cfg_attr(target_os = "teeos", allow(unused_unsafe))]
113117
unsafe {
114118
sys::init(argc, argv, sigpipe)
115119
};
116-
117-
// Remember the main thread ID to give it the correct name.
118-
// SAFETY: this is the only time and place where we call this function.
119-
unsafe { main_thread::set(thread::current_id()) };
120120
}
121121

122122
/// Clean up the thread-local runtime state. This *should* be run after all other

0 commit comments

Comments
 (0)