summary refs log tree commit diff
path: root/library/std/src/thread
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-04-05 22:33:28 +0200
committerGitHub <noreply@github.com>2024-04-05 22:33:28 +0200
commit1bffe75df6252b38c71d2b7391951e37ee829aba (patch)
tree7be4f5952a11aa33960381f6bbd4d7904f66cd69 /library/std/src/thread
parent8a6f9a1bcf714405f7f1d655e6e79c6570ad64db (diff)
parent7d008267dddcda74ebdb83d3da9b3f16c7f56973 (diff)
downloadrust-1bffe75df6252b38c71d2b7391951e37ee829aba.tar.gz
rust-1bffe75df6252b38c71d2b7391951e37ee829aba.zip
Rollup merge of #123505 - ChrisDenton:revert-121666, r=workingjubilee
Revert "Use OS thread name by default"

This reverts #121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) due to #123495 (Thread names are not always valid UTF-8).

It's not a direct revert because there have been other changes since that PR.
Diffstat (limited to 'library/std/src/thread')
-rw-r--r--library/std/src/thread/mod.rs4
-rw-r--r--library/std/src/thread/tests.rs20
2 files changed, 1 insertions, 23 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs
index f7eb92bc61e..5d9f452c556 100644
--- a/library/std/src/thread/mod.rs
+++ b/library/std/src/thread/mod.rs
@@ -694,9 +694,7 @@ pub(crate) fn set_current(thread: Thread) {
 /// In contrast to the public `current` function, this will not panic if called
 /// from inside a TLS destructor.
 pub(crate) fn try_current() -> Option<Thread> {
-    CURRENT
-        .try_with(|current| current.get_or_init(|| Thread::new(imp::Thread::get_name())).clone())
-        .ok()
+    CURRENT.try_with(|current| current.get_or_init(|| Thread::new(None)).clone()).ok()
 }
 
 /// Gets a handle to the thread that invokes it.
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs
index d33fe27b9c3..494513f2c75 100644
--- a/library/std/src/thread/tests.rs
+++ b/library/std/src/thread/tests.rs
@@ -70,26 +70,6 @@ fn test_named_thread_truncation() {
     result.unwrap().join().unwrap();
 }
 
-#[cfg(any(
-    all(target_os = "windows", not(target_vendor = "win7")),
-    target_os = "linux",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "tvos",
-    target_os = "watchos"
-))]
-#[test]
-fn test_get_os_named_thread() {
-    use crate::sys::thread::Thread;
-    // Spawn a new thread to avoid interfering with other tests running on this thread.
-    let handler = thread::spawn(|| {
-        let name = c"test me please";
-        Thread::set_name(name);
-        assert_eq!(name, Thread::get_name().unwrap().as_c_str());
-    });
-    handler.join().unwrap();
-}
-
 #[test]
 #[should_panic]
 fn test_invalid_named_thread() {