#[derive(Clone, Debug, PartialEq, Eq)]
pub enum FlycheckConfig {
- CargoCommand { command: String, all_targets: bool, all_features: bool, extra_args: Vec<String> },
- CustomCommand { command: String, args: Vec<String> },
+ CargoCommand {
+ command: String,
+ all_targets: bool,
+ all_features: bool,
+ features: Vec<String>,
+ extra_args: Vec<String>,
+ },
+ CustomCommand {
+ command: String,
+ args: Vec<String>,
+ },
}
/// Flycheck wraps the shared state and communication machinery used for
self.check_process = None;
let mut cmd = match &self.config {
- FlycheckConfig::CargoCommand { command, all_targets, all_features, extra_args } => {
+ FlycheckConfig::CargoCommand {
+ command,
+ all_targets,
+ all_features,
+ extra_args,
+ features,
+ } => {
let mut cmd = Command::new(ra_toolchain::cargo());
cmd.arg(command);
cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
}
if *all_features {
cmd.arg("--all-features");
+ } else if !features.is_empty() {
+ cmd.arg("--features");
+ cmd.arg(features.join(" "));
}
cmd.args(extra_args);
cmd
all_targets: true,
all_features: false,
extra_args: Vec::new(),
+ features: Vec::new(),
}),
inlay_hints: InlayHintsConfig {
}
// otherwise configure command customizations
_ => {
- if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets, all_features })
+ if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets, all_features, features })
= &mut self.check
{
set(value, "/checkOnSave/extraArgs", extra_args);
set(value, "/checkOnSave/command", command);
set(value, "/checkOnSave/allTargets", all_targets);
set(value, "/checkOnSave/allFeatures", all_features);
+ *features = self.cargo.features.clone();
}
}
};