about summary refs log tree commit diff
path: root/src/librustdoc/clean/cfg.rs
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2024-09-29 23:40:06 +0200
committerUrgau <urgau@numericable.fr>2024-10-04 09:09:20 +0200
commit781f1840cd37348ce4d76fff2b04e1ada531864e (patch)
tree81d780054d7f840583c73067df987f601d66483a /src/librustdoc/clean/cfg.rs
parent62ef411631efb25134e29da76fcdb7802aa94bd4 (diff)
downloadrust-781f1840cd37348ce4d76fff2b04e1ada531864e.tar.gz
rust-781f1840cd37348ce4d76fff2b04e1ada531864e.zip
Adjust rustdoc for literal boolean support
Diffstat (limited to 'src/librustdoc/clean/cfg.rs')
-rw-r--r--src/librustdoc/clean/cfg.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs
index 26739219085..53830016a80 100644
--- a/src/librustdoc/clean/cfg.rs
+++ b/src/librustdoc/clean/cfg.rs
@@ -6,7 +6,7 @@
 use std::fmt::{self, Write};
 use std::{mem, ops};
 
-use rustc_ast::{LitKind, MetaItem, MetaItemKind, NestedMetaItem};
+use rustc_ast::{LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem};
 use rustc_data_structures::fx::FxHashSet;
 use rustc_feature::Features;
 use rustc_session::parse::ParseSess;
@@ -48,6 +48,10 @@ impl Cfg {
     ) -> Result<Option<Cfg>, InvalidCfgError> {
         match nested_cfg {
             NestedMetaItem::MetaItem(ref cfg) => Cfg::parse_without(cfg, exclude),
+            NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Bool(b), .. }) => match *b {
+                true => Ok(Some(Cfg::True)),
+                false => Ok(Some(Cfg::False)),
+            },
             NestedMetaItem::Lit(ref lit) => {
                 Err(InvalidCfgError { msg: "unexpected literal", span: lit.span })
             }
@@ -120,8 +124,8 @@ impl Cfg {
     ///
     /// If the content is not properly formatted, it will return an error indicating what and where
     /// the error is.
-    pub(crate) fn parse(cfg: &MetaItem) -> Result<Cfg, InvalidCfgError> {
-        Self::parse_without(cfg, &FxHashSet::default()).map(|ret| ret.unwrap())
+    pub(crate) fn parse(cfg: &NestedMetaItem) -> Result<Cfg, InvalidCfgError> {
+        Self::parse_nested(cfg, &FxHashSet::default()).map(|ret| ret.unwrap())
     }
 
     /// Checks whether the given configuration can be matched in the current session.