Skip to content

Commit a5700cf

Browse files
committed
Add unused_macro_rules lint definition
Not fired yet.
1 parent 9ea4d41 commit a5700cf

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
303303
PATH_STATEMENTS,
304304
UNUSED_ATTRIBUTES,
305305
UNUSED_MACROS,
306+
UNUSED_MACRO_RULES,
306307
UNUSED_ALLOCATION,
307308
UNUSED_DOC_COMMENTS,
308309
UNUSED_EXTERN_CRATES,

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,35 @@ declare_lint! {
775775
"detects macros that were not used"
776776
}
777777

778+
declare_lint! {
779+
/// The `unused_macro_rules` lint detects macro rules that were not used.
780+
///
781+
/// ### Example
782+
///
783+
/// ```rust
784+
/// macro_rules! unused_empty {
785+
/// (hello) => { println!("Hello, world!") };
786+
/// () => { println!("empty") };
787+
/// }
788+
///
789+
/// fn main() {
790+
/// unused_empty!(hello);
791+
/// }
792+
/// ```
793+
///
794+
/// {{produces}}
795+
///
796+
/// ### Explanation
797+
///
798+
/// Unused macro rules may signal a mistake or unfinished code. Furthermore,
799+
/// they slow down compilation. Right now, silencing the warning is not
800+
/// supported on a single rule level, so you have to add an allow to the
801+
/// entire macro definition.
802+
pub UNUSED_MACRO_RULES,
803+
Warn,
804+
"detects macro rules that were not used"
805+
}
806+
778807
declare_lint! {
779808
/// The `warnings` lint allows you to change the level of other
780809
/// lints which produce warnings.
@@ -3138,6 +3167,7 @@ declare_lint_pass! {
31383167
OVERLAPPING_RANGE_ENDPOINTS,
31393168
BINDINGS_WITH_VARIANT_NAME,
31403169
UNUSED_MACROS,
3170+
UNUSED_MACRO_RULES,
31413171
WARNINGS,
31423172
UNUSED_FEATURES,
31433173
STABLE_FEATURES,

0 commit comments

Comments
 (0)