Skip to content

Commit c58a5c6

Browse files
committed
Add suggested good cases in docs for lifetimes lint
1 parent b4f1769 commit c58a5c6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

clippy_lints/src/lifetimes.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ declare_clippy_lint! {
2424
///
2525
/// **Example:**
2626
/// ```rust
27+
/// // Bad: unnecessary lifetime annotations
2728
/// fn in_and_out<'a>(x: &'a u8, y: u8) -> &'a u8 {
2829
/// x
2930
/// }
31+
///
32+
/// // Good
33+
/// fn elided(x: &u8, y: u8) -> &u8 {
34+
/// x
35+
/// }
3036
/// ```
3137
pub NEEDLESS_LIFETIMES,
3238
complexity,
@@ -46,9 +52,15 @@ declare_clippy_lint! {
4652
///
4753
/// **Example:**
4854
/// ```rust
55+
/// // Bad: unnecessary lifetimes
4956
/// fn unused_lifetime<'a>(x: u8) {
5057
/// // ..
5158
/// }
59+
///
60+
/// // Good
61+
/// fn no_lifetime(x: u8) {
62+
/// // ...
63+
/// }
5264
/// ```
5365
pub EXTRA_UNUSED_LIFETIMES,
5466
complexity,

0 commit comments

Comments
 (0)