From 33910f9d86cf8c283c51800085c3e863261ec5ae Mon Sep 17 00:00:00 2001 From: wangxiangqing Date: Tue, 22 Oct 2019 00:08:14 +0800 Subject: [PATCH 1/3] Deprecated proc_macro doesn't trigger warning on build library Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378 --- src/libsyntax_ext/proc_macro_harness.rs | 10 ++++++++++ .../ui/proc-macro/proc-macro-deprecated-attr.rs | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/proc-macro/proc-macro-deprecated-attr.rs diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index 96d0c3fcab1c5..bbf5b1255510f 100644 --- a/src/libsyntax_ext/proc_macro_harness.rs +++ b/src/libsyntax_ext/proc_macro_harness.rs @@ -416,6 +416,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 0000000000000..32ccc24904283 --- /dev/null +++ b/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs @@ -0,0 +1,15 @@ +// build-pass + +#![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 { + " + extern crate proc_macro; + fn foo() { } + ".parse().unwrap() +} From c027be0dd09a440927071dea69378d01322373cd Mon Sep 17 00:00:00 2001 From: wangxiangqing Date: Tue, 22 Oct 2019 00:08:14 +0800 Subject: [PATCH 2/3] Deprecated proc_macro doesn't trigger warning on build library Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378 --- src/libsyntax_ext/proc_macro_harness.rs | 1 + src/test/ui/proc-macro/proc-macro-deprecated-attr.rs | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index bbf5b1255510f..c874f1ffb1175 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); diff --git a/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs b/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs index 32ccc24904283..25ce53b70a5bd 100644 --- a/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs +++ b/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs @@ -1,4 +1,6 @@ -// build-pass +// check-pass + +#![deny(deprecated)] #![crate_type = "proc-macro"] @@ -8,8 +10,5 @@ use proc_macro::*; #[proc_macro] #[deprecated(since = "1.0.0", note = "test")] pub fn test_compile_without_warning_with_deprecated(_: TokenStream) -> TokenStream { - " - extern crate proc_macro; - fn foo() { } - ".parse().unwrap() + TokenStream::new() } From b1331563baa43819b2717a24d2cdc94e3b3a2eb5 Mon Sep 17 00:00:00 2001 From: wangxiangqing Date: Tue, 22 Oct 2019 00:08:14 +0800 Subject: [PATCH 3/3] Deprecated proc_macro doesn't trigger warning on build library Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378 --- src/test/ui/proc-macro/proc-macro-deprecated-attr.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs b/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs index 25ce53b70a5bd..f1144a4a55b16 100644 --- a/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs +++ b/src/test/ui/proc-macro/proc-macro-deprecated-attr.rs @@ -1,4 +1,6 @@ // check-pass +// force-host +// no-prefer-dynamic #![deny(deprecated)]