From 7ca4f738fb2fef89c6c55433fb676b879c95e64a Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 24 Mar 2026 17:46:20 -0700 Subject: [PATCH] net: Remove explicit Drop for ws::Chat, it no longer adds anything --- rust/net/src/chat/ws.rs | 53 ++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/rust/net/src/chat/ws.rs b/rust/net/src/chat/ws.rs index 01fd6487a..661c5a9a0 100644 --- a/rust/net/src/chat/ws.rs +++ b/rust/net/src/chat/ws.rs @@ -295,7 +295,29 @@ impl Chat { /// progress might succeed or fail, depending on the timing of sending and /// receiving requests and responses. pub async fn disconnect(&self) { - self.state.lock().await.disconnect() + let mut guard = self.state.lock().await; + + // Take the existing state and leave a cheap-to-construct temporary + // state there. + let state = std::mem::replace( + &mut *guard, + TaskState::Finished(Ok(FinishReason::LocalDisconnect)), + ); + *guard = match state { + TaskState::MaybeStillRunning { + request_tx, + response_tx, + task, + shared_h2_connection: _, + } => { + // Signal to the task, if it's still running, that it should + // quit. Do this by hanging up on it, at which point it will + // exit. + drop((request_tx, response_tx)); + TaskState::SignaledToEnd(task) + } + state @ (TaskState::SignaledToEnd(_) | TaskState::Finished(_)) => state, + }; } /// Returns `true` if the websocket is known to be connected. @@ -409,35 +431,6 @@ impl Chat { } } -impl TaskState { - fn disconnect(&mut self) { - // Take the existing state and leave a cheap-to-construct temporary - // state there. - let state = std::mem::replace(self, TaskState::Finished(Ok(FinishReason::LocalDisconnect))); - *self = match state { - TaskState::MaybeStillRunning { - request_tx, - response_tx, - task, - shared_h2_connection: _, - } => { - // Signal to the task, if it's still running, that it should - // quit. Do this by hanging up on it, at which point it will - // exit. - drop((request_tx, response_tx)); - TaskState::SignaledToEnd(task) - } - state @ (TaskState::SignaledToEnd(_) | TaskState::Finished(_)) => state, - }; - } -} - -impl Drop for Chat { - fn drop(&mut self) { - self.state.get_mut().disconnect(); - } -} - impl Responder { /// Sends a response for the associated request to the server. ///