aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/cargo_target_spec.rs
diff options
context:
space:
mode:
authorBenjamin Coenen <[email protected]>2020-05-21 09:48:42 +0100
committerBenjamin Coenen <[email protected]>2020-05-21 09:48:42 +0100
commitc6143742bd4e625d391ac3ea860be7578ab9f53f (patch)
tree43cce6b63b38ab0497c54df8850d7c23afd70e0a /crates/rust-analyzer/src/cargo_target_spec.rs
parentebaa05a4478096aaf3bc2a48d0d171a287422c7c (diff)
add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/rust-analyzer/src/cargo_target_spec.rs')
-rw-r--r--crates/rust-analyzer/src/cargo_target_spec.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs
index 5e5a17943..a2f85060b 100644
--- a/crates/rust-analyzer/src/cargo_target_spec.rs
+++ b/crates/rust-analyzer/src/cargo_target_spec.rs
@@ -4,6 +4,7 @@ use ra_ide::{FileId, RunnableKind, TestId};
4use ra_project_model::{self, ProjectWorkspace, TargetKind}; 4use ra_project_model::{self, ProjectWorkspace, TargetKind};
5 5
6use crate::{world::WorldSnapshot, Result}; 6use crate::{world::WorldSnapshot, Result};
7use ra_syntax::SmolStr;
7 8
8/// Abstract representation of Cargo target. 9/// Abstract representation of Cargo target.
9/// 10///
@@ -20,6 +21,7 @@ impl CargoTargetSpec {
20 pub(crate) fn runnable_args( 21 pub(crate) fn runnable_args(
21 spec: Option<CargoTargetSpec>, 22 spec: Option<CargoTargetSpec>,
22 kind: &RunnableKind, 23 kind: &RunnableKind,
24 features_needed: &Option<Vec<SmolStr>>,
23 ) -> Result<(Vec<String>, Vec<String>)> { 25 ) -> Result<(Vec<String>, Vec<String>)> {
24 let mut args = Vec::new(); 26 let mut args = Vec::new();
25 let mut extra_args = Vec::new(); 27 let mut extra_args = Vec::new();
@@ -73,6 +75,13 @@ impl CargoTargetSpec {
73 } 75 }
74 } 76 }
75 } 77 }
78
79 if let Some(features_needed) = features_needed {
80 features_needed.iter().for_each(|feature| {
81 args.push("--features".to_string());
82 args.push(feature.to_string());
83 });
84 }
76 Ok((args, extra_args)) 85 Ok((args, extra_args))
77 } 86 }
78 87