From 54eb87de0363cfba1d7104b8d37898fc120c029b Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 8 Jan 2021 01:08:34 +0800 Subject: Refactor out JodChild --- crates/flycheck/Cargo.toml | 1 + crates/flycheck/src/lib.rs | 23 +---------------------- 2 files changed, 2 insertions(+), 22 deletions(-) (limited to 'crates/flycheck') diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index 3d9436d69..1bad64a1b 100644 --- a/crates/flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml @@ -17,3 +17,4 @@ serde_json = "1.0.48" jod-thread = "0.1.1" toolchain = { path = "../toolchain", version = "0.0.0" } +stdx = { path = "../stdx", version = "0.0.0" } diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index d982c5f29..4388e8c67 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -5,13 +5,13 @@ use std::{ fmt, io::{self, BufReader}, - ops, path::PathBuf, process::{self, Command, Stdio}, time::Duration, }; use crossbeam_channel::{never, select, unbounded, Receiver, Sender}; +use stdx::JodChild; pub use cargo_metadata::diagnostic::{ Applicability, Diagnostic, DiagnosticCode, DiagnosticLevel, DiagnosticSpan, @@ -323,24 +323,3 @@ impl CargoActor { Ok(read_at_least_one_message) } } - -struct JodChild(process::Child); - -impl ops::Deref for JodChild { - type Target = process::Child; - fn deref(&self) -> &process::Child { - &self.0 - } -} - -impl ops::DerefMut for JodChild { - fn deref_mut(&mut self) -> &mut process::Child { - &mut self.0 - } -} - -impl Drop for JodChild { - fn drop(&mut self) { - let _ = self.0.kill(); - } -} -- cgit v1.2.3