Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

dap: Wrap Child directly in a mutex rather than through Option<_> (#40192)

Jakub Konkad6c9d00a4c95
diff --git a/crates/dap/src/transport.rs b/crates/dap/src/transport.rs
index 50ffb4b7820..fcf46626db7 100644
--- a/crates/dap/src/transport.rs
+++ b/crates/dap/src/transport.rs
@@ -649,7 +649,7 @@ impl Drop for TcpTransport {
}
pub struct StdioTransport {
- process: Mutex<Option<Child>>,
+ process: Mutex<Child>,
_stderr_task: Option<Task<()>>,
}
@@ -684,7 +684,7 @@ impl StdioTransport {
))
});
- let process = Mutex::new(Some(process));
+ let process = Mutex::new(process);
Ok(Self {
process,
@@ -699,9 +699,7 @@ impl Transport for StdioTransport {
}
fn kill(&mut self) {
- if let Some(process) = &mut *self.process.lock() {
- process.kill();
- }
+ self.process.lock().kill();
}
fn connect(
@@ -713,8 +711,7 @@ impl Transport for StdioTransport {
)>,
> {
let result = util::maybe!({
- let mut guard = self.process.lock();
- let process = guard.as_mut().context("oops")?;
+ let mut process = self.process.lock();
Ok((
Box::new(process.stdin.take().context("Cannot reconnect")?) as _,
Box::new(process.stdout.take().context("Cannot reconnect")?) as _,
@@ -730,9 +727,7 @@ impl Transport for StdioTransport {
impl Drop for StdioTransport {
fn drop(&mut self) {
- if let Some(process) = &mut *self.process.lock() {
- process.kill();
- }
+ self.process.lock().kill();
}
}