std: add comment about abort motivation

This commit is contained in:
joboet 2024-04-03 14:33:43 +02:00
parent e7b5730d36
commit 061d8731fb
No known key found for this signature in database
GPG Key ID: 704E0149B0194B3C
1 changed files with 2 additions and 0 deletions

View File

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