about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-04-01 17:24:28 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-09-27 11:29:48 +0200
commit63aefe0737d0df886955f5a3aa68db865cd97f1b (patch)
tree3e3d93701bbc219210abc3c848d6fa883e287e43 /compiler/rustc_passes/src
parent2d82c99f1e4a4e50b47f75d767b0d1d957357c1a (diff)
downloadrust-63aefe0737d0df886955f5a3aa68db865cd97f1b.tar.gz
rust-63aefe0737d0df886955f5a3aa68db865cd97f1b.zip
Strenghten checks for `doc(auto_cfg(show/hide))` attributes
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/check_attr.rs15
-rw-r--r--compiler/rustc_passes/src/errors.rs6
2 files changed, 20 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index 3dc232a35ec..38b67e2f9dc 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -1187,7 +1187,20 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
                             meta.span,
                             errors::DocAutoCfgExpectsHideOrShow,
                         );
-                    } else if item.meta_item_list().is_none() {
+                    } else if let Some(list) = item.meta_item_list() {
+                        for item in list {
+                            if item.meta_item_list().is_some() {
+                                self.tcx.emit_node_span_lint(
+                                    INVALID_DOC_ATTRIBUTES,
+                                    hir_id,
+                                    item.span(),
+                                    errors::DocAutoCfgHideShowUnexpectedItem {
+                                        attr_name: attr_name.as_str(),
+                                    },
+                                );
+                            }
+                        }
+                    } else {
                         self.tcx.emit_node_span_lint(
                             INVALID_DOC_ATTRIBUTES,
                             hir_id,
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs
index 6cc0bd6ce48..1d2428c4f9a 100644
--- a/compiler/rustc_passes/src/errors.rs
+++ b/compiler/rustc_passes/src/errors.rs
@@ -323,6 +323,12 @@ pub(crate) struct DocAutoCfgHideShowExpectsList<'a> {
 }
 
 #[derive(LintDiagnostic)]
+#[diag(passes_doc_auto_cfg_hide_show_unexpected_item)]
+pub(crate) struct DocAutoCfgHideShowUnexpectedItem<'a> {
+    pub attr_name: &'a str,
+}
+
+#[derive(LintDiagnostic)]
 #[diag(passes_doc_test_unknown_any)]
 pub(crate) struct DocTestUnknownAny {
     pub path: String,