about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-25 06:18:08 +0200
committerGitHub <noreply@github.com>2019-10-25 06:18:08 +0200
commitfb602c7e4f5f01203c63e9c6939efa8c8f7c962a (patch)
treecededba41a14352d431e09c8cc524303d74457dc /src
parent50e8c41a817b3c9139055eb13bec5108215e0e3f (diff)
parentb1331563baa43819b2717a24d2cdc94e3b3a2eb5 (diff)
downloadrust-fb602c7e4f5f01203c63e9c6939efa8c8f7c962a.tar.gz
rust-fb602c7e4f5f01203c63e9c6939efa8c8f7c962a.zip
Rollup merge of #65666 - XiangQingW:proc_macro, r=petrochenkov
Deprecated proc_macro doesn't trigger warning on build library

Fix #65189
Diffstat (limited to 'src')
-rw-r--r--src/libsyntax_ext/proc_macro_harness.rs11
-rw-r--r--src/test/ui/proc-macro/proc-macro-deprecated-attr.rs16
2 files changed, 27 insertions, 0 deletions
diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs
index 96d0c3fcab1..c874f1ffb11 100644
--- a/src/libsyntax_ext/proc_macro_harness.rs
+++ b/src/libsyntax_ext/proc_macro_harness.rs
@@ -337,6 +337,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
 //          use proc_macro::bridge::client::ProcMacro;
 //
 //          #[rustc_proc_macro_decls]
+//          #[allow(deprecated)]
 //          static DECLS: &[ProcMacro] = &[
 //              ProcMacro::custom_derive($name_trait1, &[], ::$name1);
 //              ProcMacro::custom_derive($name_trait2, &["attribute_name"], ::$name2);
@@ -416,6 +417,16 @@ fn mk_decls(
     ).map(|mut i| {
         let attr = cx.meta_word(span, sym::rustc_proc_macro_decls);
         i.attrs.push(cx.attribute(attr));
+
+        let deprecated_attr = attr::mk_nested_word_item(
+            Ident::new(sym::deprecated, span)
+        );
+        let allow_deprecated_attr = attr::mk_list_item(
+            Ident::new(sym::allow, span),
+            vec![deprecated_attr]
+        );
+        i.attrs.push(cx.attribute(allow_deprecated_attr));
+
         i
     });
 
diff --git a/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs b/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs
new file mode 100644
index 00000000000..f1144a4a55b
--- /dev/null
+++ b/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs
@@ -0,0 +1,16 @@
+// check-pass
+// force-host
+// no-prefer-dynamic
+
+#![deny(deprecated)]
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use proc_macro::*;
+
+#[proc_macro]
+#[deprecated(since = "1.0.0", note = "test")]
+pub fn test_compile_without_warning_with_deprecated(_: TokenStream) -> TokenStream {
+    TokenStream::new()
+}