From ac3ec18f4b25bd254437a232bc835629162e1380 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 21 Jan 2021 19:12:19 +0800 Subject: Added defined_features in PackageData --- crates/project_model/src/cargo_workspace.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'crates/project_model/src/cargo_workspace.rs') diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index c0ed37fc1..a09e1a9ff 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs @@ -99,8 +99,10 @@ pub struct PackageData { pub dependencies: Vec, /// Rust edition for this package pub edition: Edition, - /// List of features to activate - pub features: Vec, + /// Features provided by the crate, mapped to the features required by that feature. + pub features: FxHashMap>, + /// List of features enabled on this package + pub active_features: Vec, /// List of config flags defined by this package's build script pub cfgs: Vec, /// List of cargo-related environment variables with their value @@ -281,7 +283,8 @@ impl CargoWorkspace { is_member, edition, dependencies: Vec::new(), - features: Vec::new(), + features: meta_pkg.features.into_iter().collect(), + active_features: Vec::new(), cfgs: cfgs.get(&id).cloned().unwrap_or_default(), envs: envs.get(&id).cloned().unwrap_or_default(), out_dir: out_dir_by_id.get(&id).cloned(), @@ -328,7 +331,7 @@ impl CargoWorkspace { let dep = PackageDependency { name: dep_node.name, pkg }; packages[source].dependencies.push(dep); } - packages[source].features.extend(node.features); + packages[source].active_features.extend(node.features); } let workspace_root = AbsPathBuf::assert(meta.workspace_root); -- cgit v1.2.3