summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/flycheck
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /src/tools/rust-analyzer/crates/flycheck
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rust-analyzer/crates/flycheck')
-rw-r--r--src/tools/rust-analyzer/crates/flycheck/Cargo.toml3
-rw-r--r--src/tools/rust-analyzer/crates/flycheck/src/lib.rs31
2 files changed, 20 insertions, 14 deletions
diff --git a/src/tools/rust-analyzer/crates/flycheck/Cargo.toml b/src/tools/rust-analyzer/crates/flycheck/Cargo.toml
index 2ad32d248..514d567fc 100644
--- a/src/tools/rust-analyzer/crates/flycheck/Cargo.toml
+++ b/src/tools/rust-analyzer/crates/flycheck/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.0.0"
description = "TBD"
license = "MIT OR Apache-2.0"
edition = "2021"
-rust-version = "1.57"
+rust-version = "1.65"
[lib]
doctest = false
@@ -17,6 +17,7 @@ rustc-hash = "1.1.0"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.86"
jod-thread = "0.1.2"
+command-group = "1.0.8"
toolchain = { path = "../toolchain", version = "0.0.0" }
stdx = { path = "../stdx", version = "0.0.0" }
diff --git a/src/tools/rust-analyzer/crates/flycheck/src/lib.rs b/src/tools/rust-analyzer/crates/flycheck/src/lib.rs
index 73c3a48b4..8f93dad06 100644
--- a/src/tools/rust-analyzer/crates/flycheck/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/flycheck/src/lib.rs
@@ -10,11 +10,12 @@ use std::{
time::Duration,
};
+use command_group::{CommandGroup, GroupChild};
use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
use paths::AbsPathBuf;
use rustc_hash::FxHashMap;
use serde::Deserialize;
-use stdx::{process::streaming_output, JodChild};
+use stdx::process::streaming_output;
pub use cargo_metadata::diagnostic::{
Applicability, Diagnostic, DiagnosticCode, DiagnosticLevel, DiagnosticSpan,
@@ -39,7 +40,7 @@ pub enum InvocationLocation {
pub enum FlycheckConfig {
CargoCommand {
command: String,
- target_triple: Option<String>,
+ target_triples: Vec<String>,
all_targets: bool,
no_default_features: bool,
all_features: bool,
@@ -285,7 +286,7 @@ impl FlycheckActor {
let (mut cmd, args) = match &self.config {
FlycheckConfig::CargoCommand {
command,
- target_triple,
+ target_triples,
no_default_features,
all_targets,
all_features,
@@ -295,9 +296,11 @@ impl FlycheckActor {
} => {
let mut cmd = Command::new(toolchain::cargo());
cmd.arg(command);
- cmd.args(&["--workspace", "--message-format=json"]);
+ cmd.current_dir(&self.root);
+ cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
+ .arg(self.root.join("Cargo.toml").as_os_str());
- if let Some(target) = target_triple {
+ for target in target_triples {
cmd.args(&["--target", target.as_str()]);
}
if *all_targets {
@@ -357,10 +360,12 @@ impl FlycheckActor {
}
}
+struct JodChild(GroupChild);
+
/// A handle to a cargo process used for fly-checking.
struct CargoHandle {
/// The handle to the actual cargo process. As we cannot cancel directly from with
- /// a read syscall dropping and therefor terminating the process is our best option.
+ /// a read syscall dropping and therefore terminating the process is our best option.
child: JodChild,
thread: jod_thread::JoinHandle<io::Result<(bool, String)>>,
receiver: Receiver<CargoMessage>,
@@ -369,10 +374,10 @@ struct CargoHandle {
impl CargoHandle {
fn spawn(mut command: Command) -> std::io::Result<CargoHandle> {
command.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null());
- let mut child = JodChild::spawn(command)?;
+ let mut child = command.group_spawn().map(JodChild)?;
- let stdout = child.stdout.take().unwrap();
- let stderr = child.stderr.take().unwrap();
+ let stdout = child.0.inner().stdout.take().unwrap();
+ let stderr = child.0.inner().stderr.take().unwrap();
let (sender, receiver) = unbounded();
let actor = CargoActor::new(sender, stdout, stderr);
@@ -384,13 +389,13 @@ impl CargoHandle {
}
fn cancel(mut self) {
- let _ = self.child.kill();
- let _ = self.child.wait();
+ let _ = self.child.0.kill();
+ let _ = self.child.0.wait();
}
fn join(mut self) -> io::Result<()> {
- let _ = self.child.kill();
- let exit_status = self.child.wait()?;
+ let _ = self.child.0.kill();
+ let exit_status = self.child.0.wait()?;
let (read_at_least_one_message, error) = self.thread.join()?;
if read_at_least_one_message || exit_status.success() {
Ok(())