Skip to content

Commit 56154a1

Browse files
committed
Add example to lint docs
1 parent f1eb88b commit 56154a1

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -1228,12 +1228,40 @@ declare_lint! {
12281228
}
12291229

12301230
declare_lint! {
1231-
/// The missing_fragment_specifier warning is issued when an unused pattern in a
1231+
/// The `missing_fragment_specifier` lint is issued when an unused pattern in a
12321232
/// `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
12331233
/// followed by a fragment specifier (e.g. `:expr`).
12341234
///
12351235
/// This warning can always be fixed by removing the unused pattern in the
12361236
/// `macro_rules!` macro definition.
1237+
///
1238+
/// ### Example
1239+
///
1240+
/// ```rust,compile_fail
1241+
/// macro_rules! foo {
1242+
/// () => {};
1243+
/// ($name) => { };
1244+
/// }
1245+
///
1246+
/// fn main() {
1247+
/// foo!();
1248+
/// }
1249+
/// ```
1250+
///
1251+
/// {{produces}}
1252+
///
1253+
/// ### Explanation
1254+
///
1255+
/// To fix this, remove the unused pattern from the `macro_rules!` macro definition:
1256+
///
1257+
/// ```rust
1258+
/// macro_rules! foo {
1259+
/// () => {};
1260+
/// }
1261+
/// fn main() {
1262+
/// foo!();
1263+
/// }
1264+
/// ```
12371265
pub MISSING_FRAGMENT_SPECIFIER,
12381266
Deny,
12391267
"detects missing fragment specifiers in unused `macro_rules!` patterns",

0 commit comments

Comments
 (0)