Skip to content

Commit

Permalink
Auto merge of rust-lang#5541 - DarkEld3r:patch-1, r=flip1995
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed May 8, 2020
2 parents 78b7d49 + 1afb6e6 commit ceddf34
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions clippy_lints/src/misc_early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,25 @@ declare_clippy_lint! {
/// **Known problems:** None.
///
/// **Example:**
/// ```ignore
/// let { a: _, b: ref b, c: _ } = ..
/// ```rust
/// # struct Foo {
/// # a: i32,
/// # b: i32,
/// # c: i32,
/// # }
/// let f = Foo { a: 0, b: 0, c: 0 };
///
/// // Bad
/// match f {
/// Foo { a: _, b: 0, .. } => {},
/// Foo { a: _, b: _, c: _ } => {},
/// }
///
/// // Good
/// match f {
/// Foo { b: 0, .. } => {},
/// Foo { .. } => {},
/// }
/// ```
pub UNNEEDED_FIELD_PATTERN,
restriction,
Expand Down

0 comments on commit ceddf34

Please sign in to comment.