From eb75a644a1c4483a74027d8936b3cfb9a02b0957 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Thu, 2 Jul 2020 16:13:24 +0200 Subject: Implement rust-analyzer feature configuration to tests. --- crates/rust-analyzer/src/cargo_target_spec.rs | 23 ++++++++++++++++------- crates/rust-analyzer/src/to_proto.rs | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs index e4dd5d92d..929926cbc 100644 --- a/crates/rust-analyzer/src/cargo_target_spec.rs +++ b/crates/rust-analyzer/src/cargo_target_spec.rs @@ -21,6 +21,7 @@ pub(crate) struct CargoTargetSpec { impl CargoTargetSpec { pub(crate) fn runnable_args( + snap: &GlobalStateSnapshot, spec: Option, kind: &RunnableKind, cfgs: &[CfgExpr], @@ -78,13 +79,21 @@ impl CargoTargetSpec { } } - let mut features = Vec::new(); - for cfg in cfgs { - required_features(cfg, &mut features); - } - for feature in features { - args.push("--features".to_string()); - args.push(feature); + if snap.config.cargo.all_features { + args.push("--all-features".to_string()); + } else { + let mut features = Vec::new(); + for cfg in cfgs { + required_features(cfg, &mut features); + } + for feature in &snap.config.cargo.features { + features.push(feature.clone()); + } + features.dedup(); + for feature in features { + args.push("--features".to_string()); + args.push(feature); + } } Ok((args, extra_args)) diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 95dd8e408..652a44694 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -666,7 +666,7 @@ pub(crate) fn runnable( let workspace_root = spec.as_ref().map(|it| it.workspace_root.clone()); let target = spec.as_ref().map(|s| s.target.clone()); let (cargo_args, executable_args) = - CargoTargetSpec::runnable_args(spec, &runnable.kind, &runnable.cfg_exprs)?; + CargoTargetSpec::runnable_args(snap, spec, &runnable.kind, &runnable.cfg_exprs)?; let label = runnable.label(target); let location = location_link(snap, None, runnable.nav)?; -- cgit v1.2.3