Read default cfgs from rustc

This commit is contained in:
uHOOCCOOHu 2019-10-03 02:02:53 +08:00
parent e0100e63ae
commit 1067a1c5f6
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
8 changed files with 76 additions and 14 deletions

View file

@ -1,4 +1,6 @@
//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator
use std::iter::IntoIterator;
use ra_syntax::SmolStr;
use rustc_hash::FxHashSet;
@ -44,6 +46,14 @@ impl CfgOptions {
self
}
/// Shortcut to set features
pub fn features(mut self, iter: impl IntoIterator<Item = SmolStr>) -> CfgOptions {
for feat in iter {
self = self.key_value("feature".into(), feat);
}
self
}
pub fn remove_atom(mut self, name: &SmolStr) -> CfgOptions {
self.atoms.remove(name);
self