Skip to content

Commit

Permalink
Rollup merge of rust-lang#65666 - XiangQingW:proc_macro, r=petrochenkov
Browse files Browse the repository at this point in the history
Deprecated proc_macro doesn't trigger warning on build library

Fix rust-lang#65189
  • Loading branch information
Centril authored Oct 23, 2019
2 parents c020d64 + c027be0 commit cea5879
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libsyntax_ext/proc_macro_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
});

Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/proc-macro/proc-macro-deprecated-attr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass

#![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()
}

0 comments on commit cea5879

Please sign in to comment.