@@ -749,6 +749,10 @@ declare_lint! {
749749declare_lint ! {
750750 /// The `unused_macros` lint detects macros that were not used.
751751 ///
752+ /// Note that this lint is distinct from the `unused_macro_rules` lint,
753+ /// which checks for single rules that never match of an otherwise used
754+ /// macro, and thus never expand.
755+ ///
752756 /// ### Example
753757 ///
754758 /// ```rust
@@ -775,6 +779,45 @@ declare_lint! {
775779 "detects macros that were not used"
776780}
777781
782+ declare_lint ! {
783+ /// The `unused_macro_rules` lint detects macro rules that were not used.
784+ ///
785+ /// Note that the lint is distinct from the `unused_macros` lint, which
786+ /// fires if the entire macro is never called, while this lint fires for
787+ /// single unused rules of the macro that is otherwise used.
788+ /// `unused_macro_rules` fires only if `unused_macros` wouldn't fire.
789+ ///
790+ /// ### Example
791+ ///
792+ /// ```rust
793+ /// macro_rules! unused_empty {
794+ /// (hello) => { println!("Hello, world!") }; // This rule is unused
795+ /// () => { println!("empty") }; // This rule is used
796+ /// }
797+ ///
798+ /// fn main() {
799+ /// unused_empty!(hello);
800+ /// }
801+ /// ```
802+ ///
803+ /// {{produces}}
804+ ///
805+ /// ### Explanation
806+ ///
807+ /// Unused macro rules may signal a mistake or unfinished code. Furthermore,
808+ /// they slow down compilation. Right now, silencing the warning is not
809+ /// supported on a single rule level, so you have to add an allow to the
810+ /// entire macro definition.
811+ ///
812+ /// If you intended to export the macro to make it
813+ /// available outside of the crate, use the [`macro_export` attribute].
814+ ///
815+ /// [`macro_export` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
816+ pub UNUSED_MACRO_RULES ,
817+ Warn ,
818+ "detects macro rules that were not used"
819+ }
820+
778821declare_lint ! {
779822 /// The `warnings` lint allows you to change the level of other
780823 /// lints which produce warnings.
@@ -3138,6 +3181,7 @@ declare_lint_pass! {
31383181 OVERLAPPING_RANGE_ENDPOINTS ,
31393182 BINDINGS_WITH_VARIANT_NAME ,
31403183 UNUSED_MACROS ,
3184+ UNUSED_MACRO_RULES ,
31413185 WARNINGS ,
31423186 UNUSED_FEATURES ,
31433187 STABLE_FEATURES ,
0 commit comments