Skip to content

Commit 061d873

Browse files
committed
std: add comment about abort motivation
1 parent e7b5730 commit 061d873

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/std/src/thread/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@ thread_local! {
686686
///
687687
/// Aborts if the handle has been set already to reduce code size.
688688
pub(crate) fn set_current(thread: Thread) {
689+
// Using `unwrap` here can add ~3kB to the binary size. We have complete
690+
// control over where this is called, so just abort if there is a bug.
689691
CURRENT.with(|current| match current.set(thread) {
690692
Ok(()) => {}
691693
Err(_) => rtabort!("should only be set once"),

0 commit comments

Comments
 (0)