Skip to content

Commit e7b5730

Browse files
committed
std: reduce code size of set_current
1 parent e2cf2cb commit e7b5730

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/std/src/thread/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,12 @@ thread_local! {
684684

685685
/// Sets the thread handle for the current thread.
686686
///
687-
/// Panics if the handle has been set already or when called from a TLS destructor.
687+
/// Aborts if the handle has been set already to reduce code size.
688688
pub(crate) fn set_current(thread: Thread) {
689-
CURRENT.with(|current| current.set(thread).unwrap());
689+
CURRENT.with(|current| match current.set(thread) {
690+
Ok(()) => {}
691+
Err(_) => rtabort!("should only be set once"),
692+
});
690693
}
691694

692695
/// Gets a handle to the thread that invokes it.

0 commit comments

Comments
 (0)