Add test for #[allow] for warnings on attribute macro

This commit is contained in:
Aaron Hill 2021-07-17 08:31:13 -05:00
parent 7ca089c6d2
commit 1c1c7949ab
No known key found for this signature in database
GPG key ID: B4087E510E98B164
3 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,19 @@
// force-host
// no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::*;
#[proc_macro_attribute]
#[deprecated(since = "1.0.0", note = "test")]
pub fn attr(_: TokenStream, input: TokenStream) -> TokenStream {
input
}
#[proc_macro_attribute]
#[deprecated(since = "1.0.0", note = "test")]
pub fn attr_remove(_: TokenStream, _: TokenStream) -> TokenStream {
TokenStream::new()
}

View file

@ -0,0 +1,34 @@
// check-pass
// aux-build:call-deprecated.rs
extern crate call_deprecated;
// These first two `#[allow(deprecated)]` attributes
// do nothing, since the AST nodes for `First` and `Second`
// haven't been been assigned a `NodeId`.
// See #63221 for a discussion about how we should
// handle the interaction of 'inert' attributes and
// proc-macro attributes.
#[allow(deprecated)]
#[call_deprecated::attr] //~ WARN use of deprecated macro
struct First;
#[allow(deprecated)]
#[call_deprecated::attr_remove] //~ WARN use of deprecated macro
struct Second;
#[allow(deprecated)]
mod bar {
#[allow(deprecated)]
#[call_deprecated::attr]
struct Third;
#[allow(deprecated)]
#[call_deprecated::attr_remove]
struct Fourth;
}
fn main() {
}

View file

@ -0,0 +1,16 @@
warning: use of deprecated macro `call_deprecated::attr`: test
--> $DIR/call-deprecated.rs:14:3
|
LL | #[call_deprecated::attr]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
warning: use of deprecated macro `call_deprecated::attr_remove`: test
--> $DIR/call-deprecated.rs:18:3
|
LL | #[call_deprecated::attr_remove]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 2 warnings emitted