pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Features>) -> bool {
    match cfg.node {
        ast::MetaItemKind::List(ref mis) => {
            for mi in mis.iter() {
                if !mi.is_meta_item() {
                    handle_errors(&sess.span_diagnostic, mi.span, AttrError::UnsupportedLiteral);
                    return false;
                }
            }

            // The unwraps below may look dangerous, but we've already asserted
            // that they won't fail with the loop above.
            match &*cfg.name.as_str() {
                "any" => mis.iter().any(|mi| {
                    cfg_matches(mi.meta_item().unwrap(), sess, features)
                }),
                "all" => mis.iter().all(|mi| {
                    cfg_matches(mi.meta_item().unwrap(), sess, features)
                }),
                "not" => {
                    if mis.len() != 1 {
                        span_err!(sess.span_diagnostic, cfg.span, E0536, "expected 1 cfg-pattern");
                        return false;
                    }

                    !cfg_matches(mis[0].meta_item().unwrap(), sess, features)
                },
                p => {
                    span_err!(sess.span_diagnostic, cfg.span, E0537, "invalid predicate `{}`", p);
                    false
                }
            }
        },
        ast::MetaItemKind::Word | ast::MetaItemKind::NameValue(..) => {
            if let (Some(feats), Some(gated_cfg)) = (features, GatedCfg::gate(cfg)) {
                gated_cfg.check_and_emit(sess, feats);
            }
            sess.config.contains(&(cfg.name(), cfg.value_str()))
        }
    }
}
/// 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(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Features>) -> bool {
    match cfg.node {
        ast::MetaItemKind::List(ref mis) => {
            for mi in mis.iter() {
                if !mi.is_meta_item() {
                    handle_errors(&sess.span_diagnostic, mi.span, AttrError::UnsupportedLiteral);
                    return false;
                }
            }
            // The unwraps below may look dangerous, but we've already asserted
            // that they won't fail with the loop above.
            match &*cfg.name.as_str() {
                "any" => mis.iter().any(|mi| {
                    cfg_matches(mi.meta_item().unwrap(), sess, features)
                }),
                "all" => mis.iter().all(|mi| {
                    cfg_matches(mi.meta_item().unwrap(), sess, features)
                }),
                "not" => {
                    if mis.len() != 1 {
                        span_err!(sess.span_diagnostic, cfg.span, E0536, "expected 1 cfg-pattern");
                        return false;
                    }
                    !cfg_matches(mis[0].meta_item().unwrap(), sess, features)
                },
                p => {
                    span_err!(sess.span_diagnostic, cfg.span, E0537, "invalid predicate `{}`", p);
                    false
                }
            }
        },
        ast::MetaItemKind::Word | ast::MetaItemKind::NameValue(..) => {
            if let (Some(feats), Some(gated_cfg)) = (features, GatedCfg::gate(cfg)) {
                gated_cfg.check_and_emit(sess, feats);
            }
            sess.config.contains(&(cfg.name(), cfg.value_str()))
        }
    }
}
pub fn cfg_matches ( cfg : & ast :: MetaItem , sess : & ParseSess , features : Option < & Features > ) -> bool { match cfg . node { ast :: MetaItemKind :: List ( ref mis ) => { for mi in mis . iter ( ) { if ! mi . is_meta_item ( ) { handle_errors ( & sess . span_diagnostic , mi . span , AttrError :: UnsupportedLiteral ) ; return false ; } } // The unwraps below may look dangerous, but we've already asserted // that they won't fail with the loop above. match & * cfg . name . as_str ( ) { " " => mis . iter ( ) . any ( | mi | { cfg_matches ( mi . meta_item ( ) . unwrap ( ) , sess , features ) } ) , " " => mis . iter ( ) . all ( | mi | { cfg_matches ( mi . meta_item ( ) . unwrap ( ) , sess , features ) } ) , " " => { if mis . len ( ) != 1 { span_err ! ( sess span_diagnostic cfg span E0536 " " ) ; return false ; } ! cfg_matches ( mis [ 0 ] . meta_item ( ) . unwrap ( ) , sess , features ) } , p => { span_err ! ( sess span_diagnostic cfg span E0537 " " p ) ; false } } } , ast :: MetaItemKind :: Word | ast :: MetaItemKind :: NameValue ( .. ) => { if let ( Some ( feats ) , Some ( gated_cfg ) ) = ( features , GatedCfg :: gate ( cfg ) ) { gated_cfg . check_and_emit ( sess , feats ) ; } sess . config . contains ( & ( cfg . name ( ) , cfg . value_str ( ) ) ) } } }
Tests if a cfg-pattern matches the cfg set
Tests if a cfg - pattern matches the cfg set
cfg
&ast::MetaItem
sess
&ParseSess
features
Option<&Features>
cfg
&ast::MetaItem
sess
&ParseSess
features
Option<&Features>