librustc: adjust logic for cfg attribute and add not predicate.
This commit is contained in:
parent
a14ec73cd2
commit
429fed0c8b
1 changed files with 11 additions and 10 deletions
|
@ -185,18 +185,19 @@ pub fn metas_in_cfg(cfg: ast::crate_cfg,
|
||||||
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
|
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
|
||||||
// so we can match against them. This is the list of configurations for
|
// so we can match against them. This is the list of configurations for
|
||||||
// which the item is valid
|
// which the item is valid
|
||||||
let cfg_metas =
|
let cfg_metas = vec::filter_map(cfg_metas, |i| attr::get_meta_item_list(i));
|
||||||
vec::concat(
|
|
||||||
vec::filter_map(cfg_metas, |i| attr::get_meta_item_list(i)));
|
|
||||||
|
|
||||||
let has_cfg_metas = vec::len(cfg_metas) > 0u;
|
if cfg_metas.all(|c| c.is_empty()) { return true; }
|
||||||
if !has_cfg_metas { return true; }
|
|
||||||
|
|
||||||
for cfg_metas.each |cfg_mi| {
|
cfg_metas.any(|cfg_meta| {
|
||||||
if attr::contains(cfg, *cfg_mi) { return true; }
|
cfg_meta.all(|cfg_mi| {
|
||||||
}
|
match cfg_mi.node {
|
||||||
|
ast::meta_list(s, ref it) if *s == ~"not"
|
||||||
return false;
|
=> it.all(|mi| !attr::contains(cfg, *mi)),
|
||||||
|
_ => attr::contains(cfg, *cfg_mi)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue