mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Filter out unused cargo features from config
This commit is contained in:
parent
ee8c18cb6e
commit
35b208aaa7
6 changed files with 50 additions and 12 deletions
|
@ -10,7 +10,7 @@ use base_db::Edition;
|
|||
use cargo_metadata::{CargoOpt, MetadataCommand};
|
||||
use la_arena::{Arena, Idx};
|
||||
use paths::{AbsPath, AbsPathBuf};
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use serde::Deserialize;
|
||||
use serde_json::from_value;
|
||||
|
||||
|
@ -491,6 +491,21 @@ impl CargoWorkspace {
|
|||
None
|
||||
}
|
||||
|
||||
/// Returns the union of the features of all member crates in this workspace.
|
||||
pub fn workspace_features(&self) -> FxHashSet<String> {
|
||||
self.packages()
|
||||
.filter_map(|package| {
|
||||
let package = &self[package];
|
||||
if package.is_member {
|
||||
Some(package.features.keys().cloned())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn is_unique(&self, name: &str) -> bool {
|
||||
self.packages.iter().filter(|(_, v)| v.name == name).count() == 1
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue