Skip to content

Commit 33910f9

Browse files
committed
Deprecated proc_macro doesn't trigger warning on build library
Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378
1 parent b7a9c28 commit 33910f9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/libsyntax_ext/proc_macro_harness.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ fn mk_decls(
416416
).map(|mut i| {
417417
let attr = cx.meta_word(span, sym::rustc_proc_macro_decls);
418418
i.attrs.push(cx.attribute(attr));
419+
420+
let deprecated_attr = attr::mk_nested_word_item(
421+
Ident::new(sym::deprecated, span)
422+
);
423+
let allow_deprecated_attr = attr::mk_list_item(
424+
Ident::new(sym::allow, span),
425+
vec![deprecated_attr]
426+
);
427+
i.attrs.push(cx.attribute(allow_deprecated_attr));
428+
419429
i
420430
});
421431

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// build-pass
2+
3+
#![crate_type = "proc-macro"]
4+
5+
extern crate proc_macro;
6+
use proc_macro::*;
7+
8+
#[proc_macro]
9+
#[deprecated(since = "1.0.0", note = "test")]
10+
pub fn test_compile_without_warning_with_deprecated(_: TokenStream) -> TokenStream {
11+
"
12+
extern crate proc_macro;
13+
fn foo() { }
14+
".parse().unwrap()
15+
}

0 commit comments

Comments
 (0)