|
6 | 6 | use std::fmt::{self, Write}; |
7 | 7 | use std::{mem, ops}; |
8 | 8 |
|
9 | | -use rustc_ast::{LitKind, MetaItem, MetaItemKind, NestedMetaItem}; |
| 9 | +use rustc_ast::{LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem}; |
10 | 10 | use rustc_data_structures::fx::FxHashSet; |
11 | 11 | use rustc_feature::Features; |
12 | 12 | use rustc_session::parse::ParseSess; |
@@ -48,6 +48,10 @@ impl Cfg { |
48 | 48 | ) -> Result<Option<Cfg>, InvalidCfgError> { |
49 | 49 | match nested_cfg { |
50 | 50 | NestedMetaItem::MetaItem(ref cfg) => Cfg::parse_without(cfg, exclude), |
| 51 | + NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Bool(b), .. }) => match *b { |
| 52 | + true => Ok(Some(Cfg::True)), |
| 53 | + false => Ok(Some(Cfg::False)), |
| 54 | + }, |
51 | 55 | NestedMetaItem::Lit(ref lit) => { |
52 | 56 | Err(InvalidCfgError { msg: "unexpected literal", span: lit.span }) |
53 | 57 | } |
@@ -120,8 +124,8 @@ impl Cfg { |
120 | 124 | /// |
121 | 125 | /// If the content is not properly formatted, it will return an error indicating what and where |
122 | 126 | /// the error is. |
123 | | - pub(crate) fn parse(cfg: &MetaItem) -> Result<Cfg, InvalidCfgError> { |
124 | | - Self::parse_without(cfg, &FxHashSet::default()).map(|ret| ret.unwrap()) |
| 127 | + pub(crate) fn parse(cfg: &NestedMetaItem) -> Result<Cfg, InvalidCfgError> { |
| 128 | + Self::parse_nested(cfg, &FxHashSet::default()).map(|ret| ret.unwrap()) |
125 | 129 | } |
126 | 130 |
|
127 | 131 | /// Checks whether the given configuration can be matched in the current session. |
|
0 commit comments