aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cfg/src/lib.rs
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
committerZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
commitf05d7b41a719d848844b054a16477b29d0f063c6 (patch)
tree0a8a0946e8aef2ce64d4c13d0035ba41cce2daf3 /crates/ra_cfg/src/lib.rs
parent73ff610e41959e3e7c78a2b4b25b086883132956 (diff)
parent6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff)
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Hasn't fixed tests yet.
Diffstat (limited to 'crates/ra_cfg/src/lib.rs')
-rw-r--r--crates/ra_cfg/src/lib.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs
index 57feabcb2..cd5a0a7b6 100644
--- a/crates/ra_cfg/src/lib.rs
+++ b/crates/ra_cfg/src/lib.rs
@@ -5,7 +5,7 @@ mod cfg_expr;
5use ra_syntax::SmolStr; 5use ra_syntax::SmolStr;
6use rustc_hash::FxHashSet; 6use rustc_hash::FxHashSet;
7 7
8pub use cfg_expr::{parse_cfg, CfgExpr}; 8pub use cfg_expr::CfgExpr;
9 9
10/// Configuration options used for conditional compilition on items with `cfg` attributes. 10/// Configuration options used for conditional compilition on items with `cfg` attributes.
11/// We have two kind of options in different namespaces: atomic options like `unix`, and 11/// We have two kind of options in different namespaces: atomic options like `unix`, and
@@ -31,19 +31,21 @@ impl CfgOptions {
31 }) 31 })
32 } 32 }
33 33
34 pub fn is_cfg_enabled(&self, attr: &tt::Subtree) -> Option<bool> {
35 self.check(&parse_cfg(attr))
36 }
37
38 pub fn insert_atom(&mut self, key: SmolStr) { 34 pub fn insert_atom(&mut self, key: SmolStr) {
39 self.atoms.insert(key); 35 self.atoms.insert(key);
40 } 36 }
41 37
42 pub fn remove_atom(&mut self, name: &str) {
43 self.atoms.remove(name);
44 }
45
46 pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) { 38 pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) {
47 self.key_values.insert((key, value)); 39 self.key_values.insert((key, value));
48 } 40 }
41
42 pub fn append(&mut self, other: &CfgOptions) {
43 for atom in &other.atoms {
44 self.atoms.insert(atom.clone());
45 }
46
47 for (key, value) in &other.key_values {
48 self.key_values.insert((key.clone(), value.clone()));
49 }
50 }
49} 51}