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 From 8b77e2692cd97552b1b8d66eb51cec69695b3a5b Mon Sep 17 00:00:00 2001 From: Jade Date: Sun, 13 Jun 2021 21:41:46 -0700 Subject: Implement a config override for the default #[cfg(test)] in cargo crates Fixes crates which vanish when the 'test' cfg atom is set. Fix #7243. Fix #9203. Fix #7225. --- crates/cfg/src/lib.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/cfg') diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs index 87bf0c925..916d39a0b 100644 --- a/crates/cfg/src/lib.rs +++ b/crates/cfg/src/lib.rs @@ -52,6 +52,7 @@ impl CfgOptions { } } +#[derive(Clone, Debug, PartialEq, Eq)] pub struct CfgDiff { // Invariants: No duplicates, no atom that's both in `enable` and `disable`. enable: Vec, -- cgit v1.2.3