From 2980ba1fde50a6fc8863750b9dd7f09e3c1227ce Mon Sep 17 00:00:00 2001 From: robojumper Date: Mon, 4 May 2020 13:29:09 +0200 Subject: Support build.rs cargo:rustc-cfg --- crates/ra_cfg/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'crates/ra_cfg/src') diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs index 51d953f6e..697a04581 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/ra_cfg/src/lib.rs @@ -53,4 +53,13 @@ impl CfgOptions { pub fn insert_features(&mut self, iter: impl IntoIterator) { iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat)); } + + /// Shortcut to set cfgs + pub fn insert_cfgs(&mut self, iter: impl IntoIterator) { + iter.into_iter().for_each(|cfg| match cfg.find('=') { + Some(split) => self + .insert_key_value(cfg[0..split].into(), cfg[split + 1..].trim_matches('"').into()), + None => self.insert_atom(cfg), + }); + } } -- cgit v1.2.3 From d3110859ba4e97cf17d2c997befa92fb63bfb138 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 8 May 2020 02:56:53 +0200 Subject: Move feature desugaring to the right abstraction layer --- crates/ra_cfg/src/lib.rs | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'crates/ra_cfg/src') 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 @@ mod cfg_expr; -use std::iter::IntoIterator; - use ra_syntax::SmolStr; use rustc_hash::FxHashSet; @@ -48,18 +46,4 @@ impl CfgOptions { pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) { self.key_values.insert((key, value)); } - - /// Shortcut to set features - pub fn insert_features(&mut self, iter: impl IntoIterator) { - iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat)); - } - - /// Shortcut to set cfgs - pub fn insert_cfgs(&mut self, iter: impl IntoIterator) { - iter.into_iter().for_each(|cfg| match cfg.find('=') { - Some(split) => self - .insert_key_value(cfg[0..split].into(), cfg[split + 1..].trim_matches('"').into()), - None => self.insert_atom(cfg), - }); - } } -- cgit v1.2.3