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.
This commit is contained in:
Stanislav Tkach 2020-04-28 12:08:38 +03:00 committed by GitHub
parent 2c4d566113
commit 1afb6e6e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,