about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-12 19:23:26 +0000
committerbors <bors@rust-lang.org>2024-03-12 19:23:26 +0000
commit99e8000b92cacdc7440645e68bd914d9bde70594 (patch)
tree513eb63243d8cb6554d09e83e09e6478f0305ba2 /tests
parent92ca7c9569c030b1aedee41e25ef915801f7494e (diff)
parent3cd6fd15a5b9f654b08d22949a21273d44ef64de (diff)
downloadrust-99e8000b92cacdc7440645e68bd914d9bde70594.tar.gz
rust-99e8000b92cacdc7440645e68bd914d9bde70594.zip
Auto merge of #12466 - J-ZhengLi:issue12377, r=blyxyas
fix [`empty_docs`] trigger in proc-macro

fixes: #12377

---

changelog: fix [`empty_docs`] trigger in proc-macros
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/auxiliary/proc_macro_attr.rs13
-rw-r--r--tests/ui/empty_docs.rs17
-rw-r--r--tests/ui/empty_docs.stderr18
3 files changed, 39 insertions, 9 deletions
diff --git a/tests/ui/auxiliary/proc_macro_attr.rs b/tests/ui/auxiliary/proc_macro_attr.rs
index b550d13b0b9..a6f3b164c9b 100644
--- a/tests/ui/auxiliary/proc_macro_attr.rs
+++ b/tests/ui/auxiliary/proc_macro_attr.rs
@@ -163,3 +163,16 @@ pub fn rewrite_struct(_args: TokenStream, input: TokenStream) -> TokenStream {
 
     quote!(#item_struct).into()
 }
+
+#[proc_macro_attribute]
+pub fn with_empty_docs(_attr: TokenStream, input: TokenStream) -> TokenStream {
+    let item = parse_macro_input!(input as syn::Item);
+    let attrs: Vec<syn::Attribute> = vec![];
+    let doc_comment = "";
+    quote! {
+        #(#attrs)*
+        #[doc = #doc_comment]
+        #item
+    }
+    .into()
+}
diff --git a/tests/ui/empty_docs.rs b/tests/ui/empty_docs.rs
index 272fab7d5ca..00e64eebc5f 100644
--- a/tests/ui/empty_docs.rs
+++ b/tests/ui/empty_docs.rs
@@ -1,6 +1,9 @@
+//@aux-build:proc_macro_attr.rs
+
 #![allow(unused)]
 #![warn(clippy::empty_docs)]
 #![allow(clippy::mixed_attributes_style)]
+#![feature(extern_types)]
 
 mod outer {
     //!
@@ -67,3 +70,17 @@ mod outer {
         y: i32,
     }
 }
+
+mod issue_12377 {
+    use proc_macro_attr::with_empty_docs;
+
+    #[with_empty_docs]
+    extern "C" {
+        type Test;
+    }
+
+    #[with_empty_docs]
+    struct Foo {
+        a: u8,
+    }
+}
diff --git a/tests/ui/empty_docs.stderr b/tests/ui/empty_docs.stderr
index f12aead6aa7..28ebea22c5d 100644
--- a/tests/ui/empty_docs.stderr
+++ b/tests/ui/empty_docs.stderr
@@ -1,5 +1,5 @@
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:6:5
+  --> tests/ui/empty_docs.rs:9:5
    |
 LL |     //!
    |     ^^^
@@ -9,7 +9,7 @@ LL |     //!
    = help: to override `-D warnings` add `#[allow(clippy::empty_docs)]`
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:14:5
+  --> tests/ui/empty_docs.rs:17:5
    |
 LL |     ///
    |     ^^^
@@ -17,7 +17,7 @@ LL |     ///
    = help: consider removing or filling it
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:16:9
+  --> tests/ui/empty_docs.rs:19:9
    |
 LL |         ///
    |         ^^^
@@ -25,7 +25,7 @@ LL |         ///
    = help: consider removing or filling it
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:27:5
+  --> tests/ui/empty_docs.rs:30:5
    |
 LL |     #[doc = ""]
    |     ^^^^^^^^^^^
@@ -33,7 +33,7 @@ LL |     #[doc = ""]
    = help: consider removing or filling it
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:30:5
+  --> tests/ui/empty_docs.rs:33:5
    |
 LL | /     #[doc = ""]
 LL | |     #[doc = ""]
@@ -42,7 +42,7 @@ LL | |     #[doc = ""]
    = help: consider removing or filling it
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:37:5
+  --> tests/ui/empty_docs.rs:40:5
    |
 LL |     ///
    |     ^^^
@@ -50,7 +50,7 @@ LL |     ///
    = help: consider removing or filling it
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:50:13
+  --> tests/ui/empty_docs.rs:53:13
    |
 LL |             /*! */
    |             ^^^^^^
@@ -58,7 +58,7 @@ LL |             /*! */
    = help: consider removing or filling it
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:58:13
+  --> tests/ui/empty_docs.rs:61:13
    |
 LL |             ///
    |             ^^^
@@ -66,7 +66,7 @@ LL |             ///
    = help: consider removing or filling it
 
 error: empty doc comment
-  --> tests/ui/empty_docs.rs:66:9
+  --> tests/ui/empty_docs.rs:69:9
    |
 LL |         ///
    |         ^^^