forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/ui/lint/unused/unused-macros-malformed-rule.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|