From 1f6abb7fbae35dbd036032a6ea2a9e04307f1f55 Mon Sep 17 00:00:00 2001 From: Jade Date: Sat, 12 Jun 2021 05:16:22 -0700 Subject: 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)]`. --- crates/cfg/src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/cfg') 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 @@ -//! cfg defines conditional compiling options, `cfg` attibute parser and evaluator +//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator mod cfg_expr; mod dnf; @@ -59,6 +59,20 @@ pub struct CfgDiff { } impl CfgDiff { + /// Create a new CfgDiff. Will return None if the same item appears more than once in the set + /// of both. + pub fn new(enable: Vec, disable: Vec) -> Option { + let mut occupied = FxHashSet::default(); + for item in enable.iter().chain(disable.iter()) { + if !occupied.insert(item) { + // was present + return None; + } + } + + Some(CfgDiff { enable, disable }) + } + /// Returns the total number of atoms changed by this diff. pub fn len(&self) -> usize { self.enable.len() + self.disable.len() -- cgit v1.2.3