]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_ast/src/attr/mod.rs
New upstream version 1.60.0+dfsg1
[rustc.git] / compiler / rustc_ast / src / attr / mod.rs
index d66774040f782955855f71cc98d5e33f3f12f453..b94b8c872169306349e49b834af24dc798c3441c 100644 (file)
@@ -230,7 +230,7 @@ impl AttrItem {
     }
 
     pub fn meta_kind(&self) -> Option<MetaItemKind> {
-        Some(MetaItemKind::from_mac_args(&self.args)?)
+        MetaItemKind::from_mac_args(&self.args)
     }
 }
 
@@ -242,6 +242,17 @@ impl Attribute {
         }
     }
 
+    pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> {
+        match self.kind {
+            AttrKind::DocComment(kind, data) => Some((data, kind)),
+            AttrKind::Normal(ref item, _) if item.path == sym::doc => item
+                .meta_kind()
+                .and_then(|kind| kind.value_str())
+                .map(|data| (data, CommentKind::Line)),
+            _ => None,
+        }
+    }
+
     pub fn doc_str(&self) -> Option<Symbol> {
         match self.kind {
             AttrKind::DocComment(.., data) => Some(data),