-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team
Description
rustc
now warns about unused macros. With the following code:
macro_rules! used {
() => {};
}
macro_rules! unused { // <- This should be cleaned up.
() => {};
}
fn main() {
used!();
}
we get the warning:
warning: unused macro definition
--> src/main.rs:5:1
|
5 | / macro_rules! unused {
6 | | () => {};
7 | | }
| |_^
|
= note: `#[warn(unused_macros)]` on by default
This is really helpful while cleaning up a large meta-programming mess.
However, it does not warn about unused macro arms, so the following:
macro_rules! used_macro {
(used_arm) => {};
(unused_arm) => {}; // <-- This should be cleaned up.
}
fn main() {
used_macro!(used_arm);
}
yields no warning yet.
Following #34938, I open this issue for discussing this feature. Is this something desirable to have rustc
warn about unused macro arms?
est31
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team