Add test for #[allow]
for warnings on attribute macro
This commit is contained in:
parent
7ca089c6d2
commit
1c1c7949ab
3 changed files with 69 additions and 0 deletions
19
src/test/ui/proc-macro/auxiliary/call-deprecated.rs
Normal file
19
src/test/ui/proc-macro/auxiliary/call-deprecated.rs
Normal 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()
|
||||
}
|
34
src/test/ui/proc-macro/call-deprecated.rs
Normal file
34
src/test/ui/proc-macro/call-deprecated.rs
Normal 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() {
|
||||
}
|
16
src/test/ui/proc-macro/call-deprecated.stderr
Normal file
16
src/test/ui/proc-macro/call-deprecated.stderr
Normal 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
|
||||
|
Loading…
Add table
Reference in a new issue