add support of feature flag for runnables #4464

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen
2020-05-21 10:48:42 +02:00
parent ebaa05a447
commit c6143742bd
7 changed files with 212 additions and 19 deletions

View File

@@ -4,6 +4,7 @@ use ra_ide::{FileId, RunnableKind, TestId};
use ra_project_model::{self, ProjectWorkspace, TargetKind};
use crate::{world::WorldSnapshot, Result};
use ra_syntax::SmolStr;
/// Abstract representation of Cargo target.
///
@@ -20,6 +21,7 @@ impl CargoTargetSpec {
pub(crate) fn runnable_args(
spec: Option<CargoTargetSpec>,
kind: &RunnableKind,
features_needed: &Option<Vec<SmolStr>>,
) -> Result<(Vec<String>, Vec<String>)> {
let mut args = Vec::new();
let mut extra_args = Vec::new();
@@ -73,6 +75,13 @@ impl CargoTargetSpec {
}
}
}
if let Some(features_needed) = features_needed {
features_needed.iter().for_each(|feature| {
args.push("--features".to_string());
args.push(feature.to_string());
});
}
Ok((args, extra_args))
}