Skip to content

Commit 6f2f904

Browse files
bors[bot]matklad
andauthored
Merge #4370
4370: Move feature desugaring to the right abstraction layer r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 7be0a29 + d311085 commit 6f2f904

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

crates/ra_cfg/src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
33
mod cfg_expr;
44

5-
use std::iter::IntoIterator;
6-
75
use ra_syntax::SmolStr;
86
use rustc_hash::FxHashSet;
97

@@ -48,18 +46,4 @@ impl CfgOptions {
4846
pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) {
4947
self.key_values.insert((key, value));
5048
}
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-
}
6549
}

crates/ra_project_model/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,18 @@ impl ProjectWorkspace {
398398
let edition = cargo[pkg].edition;
399399
let cfg_options = {
400400
let mut opts = default_cfg_options.clone();
401-
opts.insert_features(cargo[pkg].features.iter().map(Into::into));
402-
opts.insert_cfgs(cargo[pkg].cfgs.iter().map(Into::into));
401+
for feature in cargo[pkg].features.iter() {
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+
}
403413
opts
404414
};
405415
let mut env = Env::default();

0 commit comments

Comments
 (0)