aboutsummaryrefslogtreecommitdiff
path: root/crates/flycheck
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
committerZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
commitf05d7b41a719d848844b054a16477b29d0f063c6 (patch)
tree0a8a0946e8aef2ce64d4c13d0035ba41cce2daf3 /crates/flycheck
parent73ff610e41959e3e7c78a2b4b25b086883132956 (diff)
parent6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff)
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Hasn't fixed tests yet.
Diffstat (limited to 'crates/flycheck')
-rw-r--r--crates/flycheck/Cargo.toml3
-rw-r--r--crates/flycheck/src/lib.rs23
2 files changed, 21 insertions, 5 deletions
diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml
index dc26b8ce7..ff8a1e568 100644
--- a/crates/flycheck/Cargo.toml
+++ b/crates/flycheck/Cargo.toml
@@ -3,6 +3,7 @@ edition = "2018"
3name = "flycheck" 3name = "flycheck"
4version = "0.1.0" 4version = "0.1.0"
5authors = ["rust-analyzer developers"] 5authors = ["rust-analyzer developers"]
6license = "MIT OR Apache-2.0"
6 7
7[lib] 8[lib]
8doctest = false 9doctest = false
@@ -10,7 +11,7 @@ doctest = false
10[dependencies] 11[dependencies]
11crossbeam-channel = "0.4.0" 12crossbeam-channel = "0.4.0"
12log = "0.4.8" 13log = "0.4.8"
13cargo_metadata = "0.10.0" 14cargo_metadata = "0.11.1"
14serde_json = "1.0.48" 15serde_json = "1.0.48"
15jod-thread = "0.1.1" 16jod-thread = "0.1.1"
16ra_toolchain = { path = "../ra_toolchain" } 17ra_toolchain = { path = "../ra_toolchain" }
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index 1023d3040..7c38f5ef9 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -14,14 +14,17 @@ use std::{
14use crossbeam_channel::{never, select, unbounded, Receiver, Sender}; 14use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
15 15
16pub use cargo_metadata::diagnostic::{ 16pub use cargo_metadata::diagnostic::{
17 Applicability, Diagnostic, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion, 17 Applicability, Diagnostic, DiagnosticCode, DiagnosticLevel, DiagnosticSpan,
18 DiagnosticSpanMacroExpansion,
18}; 19};
19 20
20#[derive(Clone, Debug, PartialEq, Eq)] 21#[derive(Clone, Debug, PartialEq, Eq)]
21pub enum FlycheckConfig { 22pub enum FlycheckConfig {
22 CargoCommand { 23 CargoCommand {
23 command: String, 24 command: String,
25 target_triple: Option<String>,
24 all_targets: bool, 26 all_targets: bool,
27 no_default_features: bool,
25 all_features: bool, 28 all_features: bool,
26 features: Vec<String>, 29 features: Vec<String>,
27 extra_args: Vec<String>, 30 extra_args: Vec<String>,
@@ -132,6 +135,7 @@ impl FlycheckActor {
132 self.cancel_check_process(); 135 self.cancel_check_process();
133 136
134 let mut command = self.check_command(); 137 let mut command = self.check_command();
138 log::info!("restart flycheck {:?}", command);
135 command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()); 139 command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null());
136 if let Ok(child) = command.spawn().map(JodChild) { 140 if let Ok(child) = command.spawn().map(JodChild) {
137 self.cargo_handle = Some(CargoHandle::spawn(child)); 141 self.cargo_handle = Some(CargoHandle::spawn(child));
@@ -176,6 +180,8 @@ impl FlycheckActor {
176 let mut cmd = match &self.config { 180 let mut cmd = match &self.config {
177 FlycheckConfig::CargoCommand { 181 FlycheckConfig::CargoCommand {
178 command, 182 command,
183 target_triple,
184 no_default_features,
179 all_targets, 185 all_targets,
180 all_features, 186 all_features,
181 extra_args, 187 extra_args,
@@ -185,14 +191,23 @@ impl FlycheckActor {
185 cmd.arg(command); 191 cmd.arg(command);
186 cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) 192 cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
187 .arg(self.workspace_root.join("Cargo.toml")); 193 .arg(self.workspace_root.join("Cargo.toml"));
194
195 if let Some(target) = target_triple {
196 cmd.args(&["--target", target.as_str()]);
197 }
188 if *all_targets { 198 if *all_targets {
189 cmd.arg("--all-targets"); 199 cmd.arg("--all-targets");
190 } 200 }
191 if *all_features { 201 if *all_features {
192 cmd.arg("--all-features"); 202 cmd.arg("--all-features");
193 } else if !features.is_empty() { 203 } else {
194 cmd.arg("--features"); 204 if *no_default_features {
195 cmd.arg(features.join(" ")); 205 cmd.arg("--no-default-features");
206 }
207 if !features.is_empty() {
208 cmd.arg("--features");
209 cmd.arg(features.join(" "));
210 }
196 } 211 }
197 cmd.args(extra_args); 212 cmd.args(extra_args);
198 cmd 213 cmd