Skip to content

Commit 787e24c

Browse files
committed
Test that the unused_macros lint works correctly if rules are malformed
The unused_macro_rules lint had a bug where it would regard all rules of a macro as unused if one rule were malformed. This bug doesn't exist with the unused_macros lint. To ensure it doesn't appear in the future, we add a test for it.
1 parent 777e136 commit 787e24c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![deny(unused_macros)]
2+
3+
macro_rules! foo { //~ ERROR: unused macro definition
4+
(v) => {};
5+
() => 0; //~ ERROR: macro rhs must be delimited
6+
}
7+
8+
macro_rules! bar {
9+
(v) => {};
10+
() => 0; //~ ERROR: macro rhs must be delimited
11+
}
12+
13+
fn main() {
14+
bar!(v);
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error: macro rhs must be delimited
2+
--> $DIR/unused-macros-malformed-rule.rs:5:11
3+
|
4+
LL | () => 0;
5+
| ^
6+
7+
error: macro rhs must be delimited
8+
--> $DIR/unused-macros-malformed-rule.rs:10:11
9+
|
10+
LL | () => 0;
11+
| ^
12+
13+
error: unused macro definition: `foo`
14+
--> $DIR/unused-macros-malformed-rule.rs:3:14
15+
|
16+
LL | macro_rules! foo {
17+
| ^^^
18+
|
19+
note: the lint level is defined here
20+
--> $DIR/unused-macros-malformed-rule.rs:1:9
21+
|
22+
LL | #![deny(unused_macros)]
23+
| ^^^^^^^^^^^^^
24+
25+
error: aborting due to 3 previous errors
26+

0 commit comments

Comments
 (0)