aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_cfg/src/lib.rs16
-rw-r--r--crates/ra_project_model/src/lib.rs14
2 files changed, 12 insertions, 18 deletions
diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs
index 697a04581..57feabcb2 100644
--- a/crates/ra_cfg/src/lib.rs
+++ b/crates/ra_cfg/src/lib.rs
@@ -2,8 +2,6 @@
2 2
3mod cfg_expr; 3mod cfg_expr;
4 4
5use std::iter::IntoIterator;
6
7use ra_syntax::SmolStr; 5use ra_syntax::SmolStr;
8use rustc_hash::FxHashSet; 6use rustc_hash::FxHashSet;
9 7
@@ -48,18 +46,4 @@ impl CfgOptions {
48 pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) { 46 pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) {
49 self.key_values.insert((key, value)); 47 self.key_values.insert((key, value));
50 } 48 }
51
52 /// Shortcut to set features
53 pub fn insert_features(&mut self, iter: impl IntoIterator<Item = SmolStr>) {
54 iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat));
55 }
56
57 /// Shortcut to set cfgs
58 pub fn insert_cfgs(&mut self, iter: impl IntoIterator<Item = SmolStr>) {
59 iter.into_iter().for_each(|cfg| match cfg.find('=') {
60 Some(split) => self
61 .insert_key_value(cfg[0..split].into(), cfg[split + 1..].trim_matches('"').into()),
62 None => self.insert_atom(cfg),
63 });
64 }
65} 49}
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 8703429d4..c226ffa57 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -398,8 +398,18 @@ impl ProjectWorkspace {
398 let edition = cargo[pkg].edition; 398 let edition = cargo[pkg].edition;
399 let cfg_options = { 399 let cfg_options = {
400 let mut opts = default_cfg_options.clone(); 400 let mut opts = default_cfg_options.clone();
401 opts.insert_features(cargo[pkg].features.iter().map(Into::into)); 401 for feature in cargo[pkg].features.iter() {
402 opts.insert_cfgs(cargo[pkg].cfgs.iter().map(Into::into)); 402 opts.insert_key_value("feature".into(), feature.into());
403 }
404 for cfg in cargo[pkg].cfgs.iter() {
405 match cfg.find('=') {
406 Some(split) => opts.insert_key_value(
407 cfg[..split].into(),
408 cfg[split + 1..].trim_matches('"').into(),
409 ),
410 None => opts.insert_atom(cfg.into()),
411 };
412 }
403 opts 413 opts
404 }; 414 };
405 let mut env = Env::default(); 415 let mut env = Env::default();