Simplify usage of UnsafeMessage::send

This commit is contained in:
bjorn3 2025-02-06 16:59:33 +00:00
parent b0b0b25c9c
commit ed91b73179

View file

@ -46,7 +46,7 @@ unsafe impl Send for UnsafeMessage {}
impl UnsafeMessage {
/// Send the message.
fn send(self) -> Result<(), mpsc::SendError<UnsafeMessage>> {
fn send(self) {
thread_local! {
/// The Sender owned by the local thread
static LOCAL_MESSAGE_SENDER: mpsc::Sender<UnsafeMessage> =
@ -55,7 +55,9 @@ impl UnsafeMessage {
.lock().unwrap()
.clone();
}
LOCAL_MESSAGE_SENDER.with(|sender| sender.send(self))
LOCAL_MESSAGE_SENDER.with(|sender| {
sender.send(self).expect("rustc thread hung up before lazy JIT request was sent")
})
}
}
@ -231,9 +233,7 @@ extern "C" fn clif_jit_fn(
) -> *const u8 {
// send the JIT request to the rustc thread, with a channel for the response
let (tx, rx) = mpsc::channel();
UnsafeMessage::JitFn { instance_ptr, trampoline_ptr, tx }
.send()
.expect("rustc thread hung up before lazy JIT request was sent");
UnsafeMessage::JitFn { instance_ptr, trampoline_ptr, tx }.send();
// block on JIT compilation result
rx.recv().expect("rustc thread hung up before responding to sent lazy JIT request")