mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
Refactor out JodChild
This commit is contained in:
parent
1347b7fa4c
commit
54eb87de03
4 changed files with 25 additions and 23 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -427,6 +427,7 @@ dependencies = [
|
|||
"jod-thread",
|
||||
"log",
|
||||
"serde_json",
|
||||
"stdx",
|
||||
"toolchain",
|
||||
]
|
||||
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//! Missing batteries for standard libraries.
|
||||
use std::time::Instant;
|
||||
use std::{ops, process, time::Instant};
|
||||
|
||||
mod macros;
|
||||
pub mod panic_context;
|
||||
|
@ -147,6 +147,27 @@ where
|
|||
left
|
||||
}
|
||||
|
||||
pub struct JodChild(pub 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();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue