Skip to content

Commit 429fed0

Browse files
committed
librustc: adjust logic for cfg attribute and add not predicate.
1 parent a14ec73 commit 429fed0

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/librustc/front/config.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,19 @@ pub fn metas_in_cfg(cfg: ast::crate_cfg,
185185
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
186186
// so we can match against them. This is the list of configurations for
187187
// which the item is valid
188-
let cfg_metas =
189-
vec::concat(
190-
vec::filter_map(cfg_metas, |i| attr::get_meta_item_list(i)));
191-
192-
let has_cfg_metas = vec::len(cfg_metas) > 0u;
193-
if !has_cfg_metas { return true; }
194-
195-
for cfg_metas.each |cfg_mi| {
196-
if attr::contains(cfg, *cfg_mi) { return true; }
197-
}
198-
199-
return false;
188+
let cfg_metas = vec::filter_map(cfg_metas, |i| attr::get_meta_item_list(i));
189+
190+
if cfg_metas.all(|c| c.is_empty()) { return true; }
191+
192+
cfg_metas.any(|cfg_meta| {
193+
cfg_meta.all(|cfg_mi| {
194+
match cfg_mi.node {
195+
ast::meta_list(s, ref it) if *s == ~"not"
196+
=> it.all(|mi| !attr::contains(cfg, *mi)),
197+
_ => attr::contains(cfg, *cfg_mi)
198+
}
199+
})
200+
})
200201
}
201202

202203

0 commit comments

Comments
 (0)