Simplify cfg representation

This commit is contained in:
Jonas Schievink 2020-10-21 13:57:12 +02:00
parent 20d369a826
commit 2bc4c1ff31
3 changed files with 41 additions and 31 deletions

View file

@ -1,6 +1,6 @@
//! See `CargoTargetSpec`
use cfg::CfgExpr;
use cfg::{CfgAtom, CfgExpr};
use ide::{FileId, RunnableKind, TestId};
use project_model::{self, TargetKind};
use vfs::AbsPathBuf;
@ -160,7 +160,9 @@ impl CargoTargetSpec {
/// Fill minimal features needed
fn required_features(cfg_expr: &CfgExpr, features: &mut Vec<String>) {
match cfg_expr {
CfgExpr::KeyValue { key, value } if key == "feature" => features.push(value.to_string()),
CfgExpr::Atom(CfgAtom::KeyValue { key, value }) if key == "feature" => {
features.push(value.to_string())
}
CfgExpr::All(preds) => {
preds.iter().for_each(|cfg| required_features(cfg, features));
}