Skip to content

Commit ceddf34

Browse files
committed
Auto merge of #5541 - DarkEld3r:patch-1, r=flip1995
Extend example for the `unneeded_field_pattern` lint Current example is incorrect (or pseudo-code) because a struct name is omitted. I have used the code from the tests instead. Perhaps this example can be made less verbose, but I think it is more convenient to see a "real" code as an example. --- changelog: extend example for the `unneeded_field_pattern` lint
2 parents 78b7d49 + 1afb6e6 commit ceddf34

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

clippy_lints/src/misc_early.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,25 @@ declare_clippy_lint! {
2424
/// **Known problems:** None.
2525
///
2626
/// **Example:**
27-
/// ```ignore
28-
/// let { a: _, b: ref b, c: _ } = ..
27+
/// ```rust
28+
/// # struct Foo {
29+
/// # a: i32,
30+
/// # b: i32,
31+
/// # c: i32,
32+
/// # }
33+
/// let f = Foo { a: 0, b: 0, c: 0 };
34+
///
35+
/// // Bad
36+
/// match f {
37+
/// Foo { a: _, b: 0, .. } => {},
38+
/// Foo { a: _, b: _, c: _ } => {},
39+
/// }
40+
///
41+
/// // Good
42+
/// match f {
43+
/// Foo { b: 0, .. } => {},
44+
/// Foo { .. } => {},
45+
/// }
2946
/// ```
3047
pub UNNEEDED_FIELD_PATTERN,
3148
restriction,

0 commit comments

Comments
 (0)