Use ast::NestedMetaItem
when evaluating cfg predicate
This commit is contained in:
parent
c3ce4e66a5
commit
57b9b1f974
11 changed files with 62 additions and 37 deletions
|
@ -5,7 +5,9 @@ use rustc_ast::token::{Delimiter, Token, TokenKind};
|
|||
use rustc_ast::tokenstream::{
|
||||
AttrTokenStream, AttrTokenTree, LazyAttrTokenStream, Spacing, TokenTree,
|
||||
};
|
||||
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem, NodeId};
|
||||
use rustc_ast::{
|
||||
self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem, NestedMetaItem, NodeId,
|
||||
};
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
|
||||
use rustc_feature::{
|
||||
|
@ -449,7 +451,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_cfg<'a>(meta_item: &'a MetaItem, sess: &Session) -> Option<&'a MetaItem> {
|
||||
pub fn parse_cfg<'a>(meta_item: &'a MetaItem, sess: &Session) -> Option<&'a NestedMetaItem> {
|
||||
let span = meta_item.span;
|
||||
match meta_item.meta_item_list() {
|
||||
None => {
|
||||
|
@ -464,9 +466,9 @@ pub fn parse_cfg<'a>(meta_item: &'a MetaItem, sess: &Session) -> Option<&'a Meta
|
|||
sess.dcx().emit_err(InvalidCfg::MultiplePredicates { span: l.span() });
|
||||
None
|
||||
}
|
||||
Some([single]) => match single.meta_item() {
|
||||
Some(meta_item) => Some(meta_item),
|
||||
None => {
|
||||
Some([single]) => match single.is_meta_item() {
|
||||
true => Some(single),
|
||||
false => {
|
||||
sess.dcx().emit_err(InvalidCfg::PredicateLiteral { span: single.span() });
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue