/// Tests if a cfg-pattern matches the cfg set
Tests if a cfg-pattern matches the cfg set
Tests if a cfg - pattern matches the cfg set
pub fn cfg_matches(cfgs: &[P<MetaItem>], cfg: &ast::MetaItem,
                   sess: &ParseSess, features: Option<&Features>)
                   -> bool {
    match cfg.node {
        ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "any" =>
            mis.iter().any(|mi| cfg_matches(cfgs, &mi, sess, features)),
        ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "all" =>
            mis.iter().all(|mi| cfg_matches(cfgs, &mi, sess, features)),
        ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "not" => {
            if mis.len() != 1 {
                span_err!(sess.span_diagnostic, cfg.span, E0536, "expected 1 cfg-pattern");
                return false;
            }
            !cfg_matches(cfgs, &mis[0], sess, features)
        }
        ast::MetaItemKind::List(ref pred, _) => {
            span_err!(sess.span_diagnostic, cfg.span, E0537, "invalid predicate `{}`", pred);
            false
        },
        ast::MetaItemKind::Word(_) | ast::MetaItemKind::NameValue(..) => {
            if let (Some(features), Some(gated_cfg)) = (features, GatedCfg::gate(cfg)) {
                gated_cfg.check_and_emit(sess, features);
            }
            contains(cfgs, cfg)
        }
    }
}
pub fn cfg_matches ( cfgs : & [ P < MetaItem > ] , cfg : & ast :: MetaItem , sess : & ParseSess , features : Option < & Features > ) -> bool { match cfg . node { ast :: MetaItemKind :: List ( ref pred , ref mis ) if & pred [ .. ] == " " => mis . iter ( ) . any ( | mi | cfg_matches ( cfgs , & mi , sess , features ) ) , ast :: MetaItemKind :: List ( ref pred , ref mis ) if & pred [ .. ] == " " => mis . iter ( ) . all ( | mi | cfg_matches ( cfgs , & mi , sess , features ) ) , ast :: MetaItemKind :: List ( ref pred , ref mis ) if & pred [ .. ] == " " => { if mis . len ( ) != 1 { span_err ! ( sess span_diagnostic cfg span E0536 " " ) ; return false ; } ! cfg_matches ( cfgs , & mis [ 0 ] , sess , features ) } ast :: MetaItemKind :: List ( ref pred , _ ) => { span_err ! ( sess span_diagnostic cfg span E0537 " " pred ) ; false } , ast :: MetaItemKind :: Word ( _ ) | ast :: MetaItemKind :: NameValue ( .. ) => { if let ( Some ( features ) , Some ( gated_cfg ) ) = ( features , GatedCfg :: gate ( cfg ) ) { gated_cfg . check_and_emit ( sess , features ) ; } contains ( cfgs , cfg ) } } }
Tests if a cfg-pattern matches the cfg set
Tests if a cfg - pattern matches the cfg set
cfgs
&[P<MetaItem>]
cfg
&ast::MetaItem
sess
&ParseSess
features
Option<&Features>