]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys/windows/mod.rs
Auto merge of #97268 - jyn514:faster-assemble, r=Mark-Simulacrum
[rust.git] / library / std / src / sys / windows / mod.rs
index 4e9d408291d2a1402a4e34a069637b3dc72c13ec..b3f6d2d0aaed4213ab80f487faf552dea345ee92 100644 (file)
@@ -1,6 +1,6 @@
 #![allow(missing_docs, nonstandard_style)]
 
-use crate::ffi::{OsStr, OsString};
+use crate::ffi::{CStr, OsStr, OsString};
 use crate::io::ErrorKind;
 use crate::os::windows::ffi::{OsStrExt, OsStringExt};
 use crate::path::PathBuf;
 // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
 pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
     stack_overflow::init();
+
+    // Normally, `thread::spawn` will call `Thread::set_name` but since this thread already
+    // exists, we have to call it ourselves.
+    thread::Thread::set_name(&CStr::from_bytes_with_nul_unchecked(b"main\0"));
 }
 
 // SAFETY: must be called only once during runtime cleanup.