From a1c187eef3ba08076aedb5154929f7eda8d1b424 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 18:26:51 +0200 Subject: Rename ra_syntax -> syntax --- crates/ra_cfg/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_cfg/src/lib.rs') diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs index cd5a0a7b6..7e025143b 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/ra_cfg/src/lib.rs @@ -2,8 +2,8 @@ mod cfg_expr; -use ra_syntax::SmolStr; use rustc_hash::FxHashSet; +use syntax::SmolStr; pub use cfg_expr::CfgExpr; -- cgit v1.2.3 From 3615758f8ebf5d2cdd5d82f10daa596acfc1a64f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:15:45 +0200 Subject: Minimize deps --- crates/ra_cfg/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_cfg/src/lib.rs') diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs index 7e025143b..6fb37bf9f 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/ra_cfg/src/lib.rs @@ -3,7 +3,7 @@ mod cfg_expr; use rustc_hash::FxHashSet; -use syntax::SmolStr; +use tt::SmolStr; pub use cfg_expr::CfgExpr; -- cgit v1.2.3 From 68c223872562a8d746d4f1045d508887a0cbca5e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:19:09 +0200 Subject: Rename ra_cfg -> cfg --- crates/ra_cfg/src/lib.rs | 51 ------------------------------------------------ 1 file changed, 51 deletions(-) delete mode 100644 crates/ra_cfg/src/lib.rs (limited to 'crates/ra_cfg/src/lib.rs') diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs deleted file mode 100644 index 6fb37bf9f..000000000 --- a/crates/ra_cfg/src/lib.rs +++ /dev/null @@ -1,51 +0,0 @@ -//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator - -mod cfg_expr; - -use rustc_hash::FxHashSet; -use tt::SmolStr; - -pub use cfg_expr::CfgExpr; - -/// Configuration options used for conditional compilition on items with `cfg` attributes. -/// We have two kind of options in different namespaces: atomic options like `unix`, and -/// key-value options like `target_arch="x86"`. -/// -/// Note that for key-value options, one key can have multiple values (but not none). -/// `feature` is an example. We have both `feature="foo"` and `feature="bar"` if features -/// `foo` and `bar` are both enabled. And here, we store key-value options as a set of tuple -/// of key and value in `key_values`. -/// -/// See: https://doc.rust-lang.org/reference/conditional-compilation.html#set-configuration-options -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct CfgOptions { - atoms: FxHashSet, - key_values: FxHashSet<(SmolStr, SmolStr)>, -} - -impl CfgOptions { - pub fn check(&self, cfg: &CfgExpr) -> Option { - cfg.fold(&|key, value| match value { - None => self.atoms.contains(key), - Some(value) => self.key_values.contains(&(key.clone(), value.clone())), - }) - } - - pub fn insert_atom(&mut self, key: SmolStr) { - self.atoms.insert(key); - } - - pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) { - self.key_values.insert((key, value)); - } - - pub fn append(&mut self, other: &CfgOptions) { - for atom in &other.atoms { - self.atoms.insert(atom.clone()); - } - - for (key, value) in &other.key_values { - self.key_values.insert((key.clone(), value.clone())); - } - } -} -- cgit v1.2.3