pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Features>) -> bool {
    eval_condition(cfg, sess, features, &mut |cfg| {
        try_gate_cfg(cfg, sess, features);
        let error = |span, msg| {
            sess.span_diagnostic.span_err(span, msg);
            true
        };
        if cfg.path.segments.len() != 1 {
            return error(cfg.path.span, "`cfg` predicate key must be an identifier");
        }
        match &cfg.kind {
            MetaItemKind::List(..) => {
                error(cfg.span, "unexpected parentheses after `cfg` predicate key")
            }
            MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
                handle_errors(
                    sess,
                    lit.span,
                    AttrError::UnsupportedLiteral(
                        "literal in `cfg` predicate value must be a string",
                        lit.kind.is_bytestr(),
                    ),
                );
                true
            }
            MetaItemKind::NameValue(..) | MetaItemKind::Word => {
                let name = cfg.ident().expect("multi-segment cfg predicate").name;
                let value = cfg.value_str();
                if sess.check_config.names_checked && !sess.check_config.names_valid.contains(&name)
                {
                    sess.buffer_lint(
                        UNEXPECTED_CFGS,
                        cfg.span,
                        CRATE_NODE_ID,
                        "unexpected `cfg` condition name",
                    );
                }
                if let Some(val) = value {
                    if sess.check_config.values_checked.contains(&name)
                        && !sess.check_config.values_valid.contains(&(name, val))
                    {
                        sess.buffer_lint(
                            UNEXPECTED_CFGS,
                            cfg.span,
                            CRATE_NODE_ID,
                            "unexpected `cfg` condition value",
                        );
                    }
                }
                sess.config.contains(&(name, value))
            }
        }
    })
}
/// 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 {
    eval_condition(cfg, sess, features, &mut |cfg| {
        try_gate_cfg(cfg, sess, features);
        let error = |span, msg| {
            sess.span_diagnostic.span_err(span, msg);
            true
        };
        if cfg.path.segments.len() != 1 {
            return error(cfg.path.span, "`cfg` predicate key must be an identifier");
        }
        match &cfg.kind {
            MetaItemKind::List(..) => {
                error(cfg.span, "unexpected parentheses after `cfg` predicate key")
            }
            MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
                handle_errors(
                    sess,
                    lit.span,
                    AttrError::UnsupportedLiteral(
                        "literal in `cfg` predicate value must be a string",
                        lit.kind.is_bytestr(),
                    ),
                );
                true
            }
            MetaItemKind::NameValue(..) | MetaItemKind::Word => {
                let name = cfg.ident().expect("multi-segment cfg predicate").name;
                let value = cfg.value_str();
                if sess.check_config.names_checked && !sess.check_config.names_valid.contains(&name)
                {
                    sess.buffer_lint(
                        UNEXPECTED_CFGS,
                        cfg.span,
                        CRATE_NODE_ID,
                        "unexpected `cfg` condition name",
                    );
                }
                if let Some(val) = value {
                    if sess.check_config.values_checked.contains(&name)
                        && !sess.check_config.values_valid.contains(&(name, val))
                    {
                        sess.buffer_lint(
                            UNEXPECTED_CFGS,
                            cfg.span,
                            CRATE_NODE_ID,
                            "unexpected `cfg` condition value",
                        );
                    }
                }
                sess.config.contains(&(name, value))
            }
        }
    })
}
pub fn cfg_matches ( cfg : & ast :: MetaItem , sess : & ParseSess , features : Option < & Features > ) -> bool { eval_condition ( cfg , sess , features , & mut | cfg | { try_gate_cfg ( cfg , sess , features ) ; let error = | span , msg | { sess . span_diagnostic . span_err ( span , msg ) ; true } ; if cfg . path . segments . len ( ) != 1 { return error ( cfg . path . span , " " ) ; } match & cfg . kind { MetaItemKind :: List ( .. ) => { error ( cfg . span , " " ) } MetaItemKind :: NameValue ( lit ) if ! lit . kind . is_str ( ) => { handle_errors ( sess , lit . span , AttrError :: UnsupportedLiteral ( " " , lit . kind . is_bytestr ( ) , ) , ) ; true } MetaItemKind :: NameValue ( .. ) | MetaItemKind :: Word => { let name = cfg . ident ( ) . expect ( " " ) . name ; let value = cfg . value_str ( ) ; if sess . check_config . names_checked && ! sess . check_config . names_valid . contains ( & name ) { sess . buffer_lint ( UNEXPECTED_CFGS , cfg . span , CRATE_NODE_ID , " " , ) ; } if let Some ( val ) = value { if sess . check_config . values_checked . contains ( & name ) && ! sess . check_config . values_valid . contains ( & ( name , val ) ) { sess . buffer_lint ( UNEXPECTED_CFGS , cfg . span , CRATE_NODE_ID , " " , ) ; } } sess . config . contains ( & ( name , value ) ) } } } ) }
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>