aboutsummaryrefslogtreecommitdiff
path: root/crates/cfg
diff options
context:
space:
mode:
authorJade <[email protected]>2021-06-12 13:16:22 +0100
committerJade <[email protected]>2021-06-19 09:09:19 +0100
commit1f6abb7fbae35dbd036032a6ea2a9e04307f1f55 (patch)
treec49a07d81e3cc3a6ea6ca3c57fd364492475c49b /crates/cfg
parent0d3bad85e60d011b35da0a8e5dd6611934f6816d (diff)
Fix libcore not being included in rust-lang/rust module tree
If you are opening libcore from rust-lang/rust as opposed to e.g. goto definition from some other crate which would use the sysroot instance of libcore, a `#![cfg(not(test))]` would previously have made all the code excluded from the module tree, breaking the editor experience. This puts in a slight hack that checks for the crate name "core" and turns off `#[cfg(test)]`.
Diffstat (limited to 'crates/cfg')
-rw-r--r--crates/cfg/src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs
index 03b8dd767..87bf0c925 100644
--- a/crates/cfg/src/lib.rs
+++ b/crates/cfg/src/lib.rs
@@ -1,4 +1,4 @@
1//! cfg defines conditional compiling options, `cfg` attibute parser and evaluator 1//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator
2 2
3mod cfg_expr; 3mod cfg_expr;
4mod dnf; 4mod dnf;
@@ -59,6 +59,20 @@ pub struct CfgDiff {
59} 59}
60 60
61impl CfgDiff { 61impl CfgDiff {
62 /// Create a new CfgDiff. Will return None if the same item appears more than once in the set
63 /// of both.
64 pub fn new(enable: Vec<CfgAtom>, disable: Vec<CfgAtom>) -> Option<CfgDiff> {
65 let mut occupied = FxHashSet::default();
66 for item in enable.iter().chain(disable.iter()) {
67 if !occupied.insert(item) {
68 // was present
69 return None;
70 }
71 }
72
73 Some(CfgDiff { enable, disable })
74 }
75
62 /// Returns the total number of atoms changed by this diff. 76 /// Returns the total number of atoms changed by this diff.
63 pub fn len(&self) -> usize { 77 pub fn len(&self) -> usize {
64 self.enable.len() + self.disable.len() 78 self.enable.len() + self.disable.len()