1
Fork 0

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.
This commit is contained in:
est31 2022-06-09 23:46:40 +02:00
parent 777e136f4c
commit 787e24cdfd
2 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#![deny(unused_macros)]
macro_rules! foo { //~ ERROR: unused macro definition
(v) => {};
() => 0; //~ ERROR: macro rhs must be delimited
}
macro_rules! bar {
(v) => {};
() => 0; //~ ERROR: macro rhs must be delimited
}
fn main() {
bar!(v);
}

View file

@ -0,0 +1,26 @@
error: macro rhs must be delimited
--> $DIR/unused-macros-malformed-rule.rs:5:11
|
LL | () => 0;
| ^
error: macro rhs must be delimited
--> $DIR/unused-macros-malformed-rule.rs:10:11
|
LL | () => 0;
| ^
error: unused macro definition: `foo`
--> $DIR/unused-macros-malformed-rule.rs:3:14
|
LL | macro_rules! foo {
| ^^^
|
note: the lint level is defined here
--> $DIR/unused-macros-malformed-rule.rs:1:9
|
LL | #![deny(unused_macros)]
| ^^^^^^^^^^^^^
error: aborting due to 3 previous errors