Skip to content

Commit 1c1c794

Browse files
committed
Add test for #[allow] for warnings on attribute macro
1 parent 7ca089c commit 1c1c794

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
#![crate_type = "proc-macro"]
5+
6+
extern crate proc_macro;
7+
use proc_macro::*;
8+
9+
#[proc_macro_attribute]
10+
#[deprecated(since = "1.0.0", note = "test")]
11+
pub fn attr(_: TokenStream, input: TokenStream) -> TokenStream {
12+
input
13+
}
14+
15+
#[proc_macro_attribute]
16+
#[deprecated(since = "1.0.0", note = "test")]
17+
pub fn attr_remove(_: TokenStream, _: TokenStream) -> TokenStream {
18+
TokenStream::new()
19+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// check-pass
2+
// aux-build:call-deprecated.rs
3+
4+
extern crate call_deprecated;
5+
6+
// These first two `#[allow(deprecated)]` attributes
7+
// do nothing, since the AST nodes for `First` and `Second`
8+
// haven't been been assigned a `NodeId`.
9+
// See #63221 for a discussion about how we should
10+
// handle the interaction of 'inert' attributes and
11+
// proc-macro attributes.
12+
13+
#[allow(deprecated)]
14+
#[call_deprecated::attr] //~ WARN use of deprecated macro
15+
struct First;
16+
17+
#[allow(deprecated)]
18+
#[call_deprecated::attr_remove] //~ WARN use of deprecated macro
19+
struct Second;
20+
21+
#[allow(deprecated)]
22+
mod bar {
23+
#[allow(deprecated)]
24+
#[call_deprecated::attr]
25+
struct Third;
26+
27+
#[allow(deprecated)]
28+
#[call_deprecated::attr_remove]
29+
struct Fourth;
30+
}
31+
32+
33+
fn main() {
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: use of deprecated macro `call_deprecated::attr`: test
2+
--> $DIR/call-deprecated.rs:14:3
3+
|
4+
LL | #[call_deprecated::attr]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(deprecated)]` on by default
8+
9+
warning: use of deprecated macro `call_deprecated::attr_remove`: test
10+
--> $DIR/call-deprecated.rs:18:3
11+
|
12+
LL | #[call_deprecated::attr_remove]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
warning: 2 warnings emitted
16+

0 commit comments

Comments
 (0)