Skip to content

Commit 483668b

Browse files
committed
Add example to lint docs
1 parent f2c8a38 commit 483668b

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
@@ -1229,12 +1229,40 @@ declare_lint! {
12291229
}
12301230

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

0 commit comments

Comments
 (0)