diff options
| author | bors <bors@rust-lang.org> | 2020-05-08 10:34:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-05-08 10:34:50 +0000 |
| commit | ceddf34b2ec054e704166914da0e1fe0cab1a45c (patch) | |
| tree | 36f7ecb58fb9541b988fc7891b0620060b6cfc1c | |
| parent | 78b7d4944c64cb6810c168bcd7edc4e900169464 (diff) | |
| parent | 1afb6e6e3b23bd5555f34cc4dcd20349dfd789de (diff) | |
| download | rust-ceddf34b2ec054e704166914da0e1fe0cab1a45c.tar.gz rust-ceddf34b2ec054e704166914da0e1fe0cab1a45c.zip | |
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
| -rw-r--r-- | clippy_lints/src/misc_early.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index adfd8dfb1c1..62ee051624b 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -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, |
