From 33910f9d86cf8c283c51800085c3e863261ec5ae Mon Sep 17 00:00:00 2001 From: wangxiangqing Date: Tue, 22 Oct 2019 00:08:14 +0800 Subject: Deprecated proc_macro doesn't trigger warning on build library Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378 --- src/libsyntax_ext/proc_macro_harness.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libsyntax_ext') diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index 96d0c3fcab1..bbf5b125551 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 }); -- cgit 1.4.1-3-g733a5 From c027be0dd09a440927071dea69378d01322373cd Mon Sep 17 00:00:00 2001 From: wangxiangqing Date: Tue, 22 Oct 2019 00:08:14 +0800 Subject: 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(-) (limited to 'src/libsyntax_ext') diff --git a/src/libsyntax_ext/proc_macro_harness.rs b/src/libsyntax_ext/proc_macro_harness.rs index bbf5b125551..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); 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 32ccc249042..25ce53b70a5 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() } -- cgit 1.4.1-3-g733a5