Skip to content

Commit eb75a64

Browse files
committed
Implement rust-analyzer feature configuration to tests.
1 parent 57ed622 commit eb75a64

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

crates/rust-analyzer/src/cargo_target_spec.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub(crate) struct CargoTargetSpec {
2121

2222
impl CargoTargetSpec {
2323
pub(crate) fn runnable_args(
24+
snap: &GlobalStateSnapshot,
2425
spec: Option<CargoTargetSpec>,
2526
kind: &RunnableKind,
2627
cfgs: &[CfgExpr],
@@ -78,13 +79,21 @@ impl CargoTargetSpec {
7879
}
7980
}
8081

81-
let mut features = Vec::new();
82-
for cfg in cfgs {
83-
required_features(cfg, &mut features);
84-
}
85-
for feature in features {
86-
args.push("--features".to_string());
87-
args.push(feature);
82+
if snap.config.cargo.all_features {
83+
args.push("--all-features".to_string());
84+
} else {
85+
let mut features = Vec::new();
86+
for cfg in cfgs {
87+
required_features(cfg, &mut features);
88+
}
89+
for feature in &snap.config.cargo.features {
90+
features.push(feature.clone());
91+
}
92+
features.dedup();
93+
for feature in features {
94+
args.push("--features".to_string());
95+
args.push(feature);
96+
}
8897
}
8998

9099
Ok((args, extra_args))

crates/rust-analyzer/src/to_proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ pub(crate) fn runnable(
666666
let workspace_root = spec.as_ref().map(|it| it.workspace_root.clone());
667667
let target = spec.as_ref().map(|s| s.target.clone());
668668
let (cargo_args, executable_args) =
669-
CargoTargetSpec::runnable_args(spec, &runnable.kind, &runnable.cfg_exprs)?;
669+
CargoTargetSpec::runnable_args(snap, spec, &runnable.kind, &runnable.cfg_exprs)?;
670670
let label = runnable.label(target);
671671
let location = location_link(snap, None, runnable.nav)?;
672672

0 commit comments

Comments
 (0)