diff options
-rw-r--r-- | crates/flycheck/src/lib.rs | 13 | ||||
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 29 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 5 | ||||
-rw-r--r-- | editors/code/package.json | 8 |
4 files changed, 41 insertions, 14 deletions
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index ad376ad18..7c38f5ef9 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs | |||
@@ -24,6 +24,7 @@ pub enum FlycheckConfig { | |||
24 | command: String, | 24 | command: String, |
25 | target_triple: Option<String>, | 25 | target_triple: Option<String>, |
26 | all_targets: bool, | 26 | all_targets: bool, |
27 | no_default_features: bool, | ||
27 | all_features: bool, | 28 | all_features: bool, |
28 | features: Vec<String>, | 29 | features: Vec<String>, |
29 | extra_args: Vec<String>, | 30 | extra_args: Vec<String>, |
@@ -180,6 +181,7 @@ impl FlycheckActor { | |||
180 | FlycheckConfig::CargoCommand { | 181 | FlycheckConfig::CargoCommand { |
181 | command, | 182 | command, |
182 | target_triple, | 183 | target_triple, |
184 | no_default_features, | ||
183 | all_targets, | 185 | all_targets, |
184 | all_features, | 186 | all_features, |
185 | extra_args, | 187 | extra_args, |
@@ -198,9 +200,14 @@ impl FlycheckActor { | |||
198 | } | 200 | } |
199 | if *all_features { | 201 | if *all_features { |
200 | cmd.arg("--all-features"); | 202 | cmd.arg("--all-features"); |
201 | } else if !features.is_empty() { | 203 | } else { |
202 | cmd.arg("--features"); | 204 | if *no_default_features { |
203 | 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 | } | ||
204 | } | 211 | } |
205 | cmd.args(extra_args); | 212 | cmd.args(extra_args); |
206 | cmd | 213 | cmd |
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index fb88e0f06..10513542e 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -144,12 +144,15 @@ impl CargoWorkspace { | |||
144 | meta.manifest_path(cargo_toml.to_path_buf()); | 144 | meta.manifest_path(cargo_toml.to_path_buf()); |
145 | if cargo_features.all_features { | 145 | if cargo_features.all_features { |
146 | meta.features(CargoOpt::AllFeatures); | 146 | meta.features(CargoOpt::AllFeatures); |
147 | } else if cargo_features.no_default_features { | 147 | } else { |
148 | // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` | 148 | if cargo_features.no_default_features { |
149 | // https://github.com/oli-obk/cargo_metadata/issues/79 | 149 | // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` |
150 | meta.features(CargoOpt::NoDefaultFeatures); | 150 | // https://github.com/oli-obk/cargo_metadata/issues/79 |
151 | } else if !cargo_features.features.is_empty() { | 151 | meta.features(CargoOpt::NoDefaultFeatures); |
152 | meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone())); | 152 | } |
153 | if !cargo_features.features.is_empty() { | ||
154 | meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone())); | ||
155 | } | ||
153 | } | 156 | } |
154 | if let Some(parent) = cargo_toml.parent() { | 157 | if let Some(parent) = cargo_toml.parent() { |
155 | meta.current_dir(parent.to_path_buf()); | 158 | meta.current_dir(parent.to_path_buf()); |
@@ -289,12 +292,16 @@ pub fn load_extern_resources( | |||
289 | cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); | 292 | cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); |
290 | if cargo_features.all_features { | 293 | if cargo_features.all_features { |
291 | cmd.arg("--all-features"); | 294 | cmd.arg("--all-features"); |
292 | } else if cargo_features.no_default_features { | ||
293 | // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` | ||
294 | // https://github.com/oli-obk/cargo_metadata/issues/79 | ||
295 | cmd.arg("--no-default-features"); | ||
296 | } else { | 295 | } else { |
297 | cmd.args(&cargo_features.features); | 296 | if cargo_features.no_default_features { |
297 | // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` | ||
298 | // https://github.com/oli-obk/cargo_metadata/issues/79 | ||
299 | cmd.arg("--no-default-features"); | ||
300 | } | ||
301 | if !cargo_features.features.is_empty() { | ||
302 | cmd.arg("--features"); | ||
303 | cmd.arg(cargo_features.features.join(" ")); | ||
304 | } | ||
298 | } | 305 | } |
299 | 306 | ||
300 | let output = cmd.output()?; | 307 | let output = cmd.output()?; |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index e11c8b909..70b4512d0 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -151,6 +151,7 @@ impl Config { | |||
151 | flycheck: Some(FlycheckConfig::CargoCommand { | 151 | flycheck: Some(FlycheckConfig::CargoCommand { |
152 | command: "check".to_string(), | 152 | command: "check".to_string(), |
153 | target_triple: None, | 153 | target_triple: None, |
154 | no_default_features: false, | ||
154 | all_targets: true, | 155 | all_targets: true, |
155 | all_features: false, | 156 | all_features: false, |
156 | extra_args: Vec::new(), | 157 | extra_args: Vec::new(), |
@@ -234,6 +235,9 @@ impl Config { | |||
234 | command: data.checkOnSave_command, | 235 | command: data.checkOnSave_command, |
235 | target_triple: data.checkOnSave_target.or(data.cargo_target), | 236 | target_triple: data.checkOnSave_target.or(data.cargo_target), |
236 | all_targets: data.checkOnSave_allTargets, | 237 | all_targets: data.checkOnSave_allTargets, |
238 | no_default_features: data | ||
239 | .checkOnSave_noDefaultFeatures | ||
240 | .unwrap_or(data.cargo_noDefaultFeatures), | ||
237 | all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), | 241 | all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), |
238 | features: data.checkOnSave_features.unwrap_or(data.cargo_features), | 242 | features: data.checkOnSave_features.unwrap_or(data.cargo_features), |
239 | extra_args: data.checkOnSave_extraArgs, | 243 | extra_args: data.checkOnSave_extraArgs, |
@@ -398,6 +402,7 @@ config_data! { | |||
398 | checkOnSave_allFeatures: Option<bool> = None, | 402 | checkOnSave_allFeatures: Option<bool> = None, |
399 | checkOnSave_allTargets: bool = true, | 403 | checkOnSave_allTargets: bool = true, |
400 | checkOnSave_command: String = "check".into(), | 404 | checkOnSave_command: String = "check".into(), |
405 | checkOnSave_noDefaultFeatures: Option<bool> = None, | ||
401 | checkOnSave_target: Option<String> = None, | 406 | checkOnSave_target: Option<String> = None, |
402 | checkOnSave_extraArgs: Vec<String> = Vec::new(), | 407 | checkOnSave_extraArgs: Vec<String> = Vec::new(), |
403 | checkOnSave_features: Option<Vec<String>> = None, | 408 | checkOnSave_features: Option<Vec<String>> = None, |
diff --git a/editors/code/package.json b/editors/code/package.json index 658c913fd..1adf055d0 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -323,6 +323,14 @@ | |||
323 | "default": true, | 323 | "default": true, |
324 | "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" | 324 | "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" |
325 | }, | 325 | }, |
326 | "rust-analyzer.checkOnSave.noDefaultFeatures": { | ||
327 | "type": [ | ||
328 | "null", | ||
329 | "boolean" | ||
330 | ], | ||
331 | "default": null, | ||
332 | "markdownDescription": "Do not activate the `default` feature" | ||
333 | }, | ||
326 | "rust-analyzer.checkOnSave.allFeatures": { | 334 | "rust-analyzer.checkOnSave.allFeatures": { |
327 | "type": [ | 335 | "type": [ |
328 | "null", | 336 | "null", |