From 1067a1c5f649cc206e35b427eaa8d6553280cc96 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Thu, 3 Oct 2019 02:02:53 +0800 Subject: Read default cfgs from rustc --- crates/ra_cfg/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/ra_cfg/src/lib.rs') diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs index dd81a73f4..e1c92fbba 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/ra_cfg/src/lib.rs @@ -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) -> 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 -- cgit v1.2.3