Skip to content

Commit d69f6ba

Browse files
Add regression test
1 parent 7c72d54 commit d69f6ba

2 files changed

Lines changed: 191 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//@ check-pass
2+
#![feature(sanitize)]
3+
#![feature(register_tool)]
4+
#![feature(export_stable)]
5+
#![feature(lang_items)]
6+
#![feature(dropck_eyepatch)]
7+
#![feature(diagnostic_on_const)]
8+
#![feature(diagnostic_on_move)]
9+
#![feature(diagnostic_on_unknown)]
10+
#![feature(diagnostic_on_unmatch_args)]
11+
#![warn(unused)]
12+
13+
macro_rules! test { () => {} }
14+
15+
#[doc = ""]
16+
//~^ WARN unused doc comment
17+
#[diagnostic::do_not_recommend]
18+
//~^ WARN can only be placed on trait implementations
19+
#[diagnostic::on_const]
20+
//~^ WARN can only be applied to non-const trait implementations
21+
#[diagnostic::on_move]
22+
//~^ WARN can only be applied to enums, structs or unions
23+
#[diagnostic::on_unimplemented]
24+
//~^ WARN can only be applied to trait definitions
25+
#[diagnostic::on_unknown]
26+
//~^ WARN can only be applied to `use` statements
27+
#[diagnostic::on_unmatch_args]
28+
//~^ WARN can only be applied to macro definitions
29+
#[sanitize()]
30+
//~^ WARN attribute cannot be used on macro calls
31+
//~| WARN previously accepted
32+
#[register_tool(test)]
33+
//~^ WARN attribute cannot be used on macro calls
34+
//~| WARN previously accepted
35+
#[link(name = "x")]
36+
//~^ WARN attribute cannot be used on macro calls
37+
//~| WARN previously accepted
38+
#[export_stable]
39+
//~^ WARN attribute cannot be used on macro calls
40+
//~| WARN previously accepted
41+
#[repr(align(64))]
42+
//~^ WARN attribute cannot be used on macro calls
43+
//~| WARN previously accepted
44+
#[lang = "sized"]
45+
//~^ WARN attribute cannot be used on macro calls
46+
//~| WARN previously accepted
47+
#[panic_handler]
48+
//~^ WARN attribute cannot be used on macro calls
49+
//~| WARN previously accepted
50+
#[may_dangle]
51+
//~^ WARN attribute cannot be used on macro calls
52+
//~| WARN previously accepted
53+
test!();
54+
55+
fn main() {}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
warning: unused doc comment
2+
--> $DIR/macro-call-attr.rs:15:1
3+
|
4+
LL | #[doc = ""]
5+
| ^^^^^^^^^^^ rustdoc does not generate documentation for macro invocations
6+
|
7+
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
8+
note: the lint level is defined here
9+
--> $DIR/macro-call-attr.rs:11:9
10+
|
11+
LL | #![warn(unused)]
12+
| ^^^^^^
13+
= note: `#[warn(unused_doc_comments)]` implied by `#[warn(unused)]`
14+
15+
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
16+
--> $DIR/macro-call-attr.rs:17:1
17+
|
18+
LL | #[diagnostic::do_not_recommend]
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
...
21+
LL | test!();
22+
| ------- not a trait implementation
23+
|
24+
= note: `#[warn(misplaced_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default
25+
26+
warning: `#[diagnostic::on_const]` can only be applied to non-const trait implementations
27+
--> $DIR/macro-call-attr.rs:19:1
28+
|
29+
LL | #[diagnostic::on_const]
30+
| ^^^^^^^^^^^^^^^^^^^^^^^
31+
...
32+
LL | test!();
33+
| ------- not a trait implementation
34+
35+
warning: `#[diagnostic::on_move]` can only be applied to enums, structs or unions
36+
--> $DIR/macro-call-attr.rs:21:1
37+
|
38+
LL | #[diagnostic::on_move]
39+
| ^^^^^^^^^^^^^^^^^^^^^^
40+
41+
warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definitions
42+
--> $DIR/macro-call-attr.rs:23:1
43+
|
44+
LL | #[diagnostic::on_unimplemented]
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
47+
warning: `#[diagnostic::on_unknown]` can only be applied to `use` statements
48+
--> $DIR/macro-call-attr.rs:25:1
49+
|
50+
LL | #[diagnostic::on_unknown]
51+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
52+
...
53+
LL | test!();
54+
| ------- not an import
55+
56+
warning: `#[diagnostic::on_unmatch_args]` can only be applied to macro definitions
57+
--> $DIR/macro-call-attr.rs:27:1
58+
|
59+
LL | #[diagnostic::on_unmatch_args]
60+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61+
62+
warning: `#[sanitize]` attribute cannot be used on macro calls
63+
--> $DIR/macro-call-attr.rs:29:1
64+
|
65+
LL | #[sanitize()]
66+
| ^^^^^^^^^^^^^
67+
|
68+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
69+
= help: `#[sanitize]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
70+
= note: `#[warn(unused_attributes)]` implied by `#[warn(unused)]`
71+
72+
warning: `#[register_tool]` attribute cannot be used on macro calls
73+
--> $DIR/macro-call-attr.rs:32:1
74+
|
75+
LL | #[register_tool(test)]
76+
| ^^^^^^^^^^^^^^^^^^^^^^
77+
|
78+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
79+
= help: `#[register_tool]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
80+
81+
warning: `#[link]` attribute cannot be used on macro calls
82+
--> $DIR/macro-call-attr.rs:35:1
83+
|
84+
LL | #[link(name = "x")]
85+
| ^^^^^^^^^^^^^^^^^^^
86+
|
87+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
88+
= help: `#[link]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
89+
90+
warning: `#[export_stable]` attribute cannot be used on macro calls
91+
--> $DIR/macro-call-attr.rs:38:1
92+
|
93+
LL | #[export_stable]
94+
| ^^^^^^^^^^^^^^^^
95+
|
96+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
97+
= help: `#[export_stable]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
98+
99+
warning: `#[repr]` attribute cannot be used on macro calls
100+
--> $DIR/macro-call-attr.rs:41:1
101+
|
102+
LL | #[repr(align(64))]
103+
| ^^^^^^^^^^^^^^^^^^
104+
|
105+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
106+
= help: `#[repr]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
107+
108+
warning: `#[lang]` attribute cannot be used on macro calls
109+
--> $DIR/macro-call-attr.rs:44:1
110+
|
111+
LL | #[lang = "sized"]
112+
| ^^^^^^^^^^^^^^^^^
113+
|
114+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
115+
= help: `#[lang]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
116+
117+
warning: `#[panic_handler]` attribute cannot be used on macro calls
118+
--> $DIR/macro-call-attr.rs:47:1
119+
|
120+
LL | #[panic_handler]
121+
| ^^^^^^^^^^^^^^^^
122+
|
123+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
124+
= help: `#[panic_handler]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
125+
126+
warning: `#[may_dangle]` attribute cannot be used on macro calls
127+
--> $DIR/macro-call-attr.rs:50:1
128+
|
129+
LL | #[may_dangle]
130+
| ^^^^^^^^^^^^^
131+
|
132+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
133+
= help: `#[may_dangle]` can be applied to associated consts, associated types, const parameters, const parameters, constants, crates, data types, enum variants, extern crates, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, lifetime parameters, macro defs, match arms, modules, pattern fields, statics, struct fields, struct fields, trait aliases, traits, type aliases, type parameters, type parameters, use statements, and where predicates
134+
135+
warning: 15 warnings emitted
136+

0 commit comments

Comments
 (0)