Skip to content

Commit

Permalink
Add example to lint docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Dec 22, 2020
1 parent f1eb88b commit 56154a1
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,12 +1228,40 @@ declare_lint! {
}

declare_lint! {
/// The missing_fragment_specifier warning is issued when an unused pattern in a
/// The `missing_fragment_specifier` lint is issued when an unused pattern in a
/// `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
/// followed by a fragment specifier (e.g. `:expr`).
///
/// This warning can always be fixed by removing the unused pattern in the
/// `macro_rules!` macro definition.
///
/// ### Example
///
/// ```rust,compile_fail
/// macro_rules! foo {
/// () => {};
/// ($name) => { };
/// }
///
/// fn main() {
/// foo!();
/// }
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// To fix this, remove the unused pattern from the `macro_rules!` macro definition:
///
/// ```rust
/// macro_rules! foo {
/// () => {};
/// }
/// fn main() {
/// foo!();
/// }
/// ```
pub MISSING_FRAGMENT_SPECIFIER,
Deny,
"detects missing fragment specifiers in unused `macro_rules!` patterns",
Expand Down

0 comments on commit 56154a1

Please sign in to comment.