mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
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)]`.
This commit is contained in:
parent
0d3bad85e6
commit
1f6abb7fba
2 changed files with 30 additions and 2 deletions
|
@ -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<CfgAtom>, disable: Vec<CfgAtom>) -> Option<CfgDiff> {
|
||||
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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue