More clean up

This commit is contained in:
Guillaume Gomez 2022-01-20 22:13:32 +01:00
parent caec4a23f2
commit b0df7653d0
2 changed files with 4 additions and 8 deletions

View File

@ -87,11 +87,8 @@ fn parse_nested(
}),
},
MetaItemKind::List(ref items) => {
let sub_cfgs = items.iter().filter_map(|i| match Cfg::parse_nested(i, exclude) {
Ok(Some(c)) => Some(Ok(c)),
Err(e) => Some(Err(e)),
_ => None,
});
let sub_cfgs =
items.iter().filter_map(|i| Cfg::parse_nested(i, exclude).transpose());
let ret = match name {
sym::all => sub_cfgs.fold(Ok(Cfg::True), |x, y| Ok(x? & y?)),
sym::any => sub_cfgs.fold(Ok(Cfg::False), |x, y| Ok(x? | y?)),

View File

@ -831,9 +831,8 @@ fn single<T: IntoIterator>(it: T) -> Option<T::Item> {
self.iter()
.filter(|attr| attr.has_name(sym::cfg))
.filter_map(|attr| single(attr.meta_item_list()?))
.filter_map(|attr| match Cfg::parse_without(attr.meta_item()?, hidden_cfg) {
Ok(Some(c)) => Some(c),
_ => None,
.filter_map(|attr| {
Cfg::parse_without(attr.meta_item()?, hidden_cfg).ok().flatten()
})
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
} else {