From c58a5c6272f1846b0c5fd7726970183dcccdfe59 Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Tue, 19 Nov 2019 20:03:41 +0100 Subject: [PATCH 1/2] Add suggested good cases in docs for lifetimes lint --- clippy_lints/src/lifetimes.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index fad54c3de659..fe8938c581fa 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -24,9 +24,15 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust + /// // Bad: unnecessary lifetime annotations /// fn in_and_out<'a>(x: &'a u8, y: u8) -> &'a u8 { /// x /// } + /// + /// // Good + /// fn elided(x: &u8, y: u8) -> &u8 { + /// x + /// } /// ``` pub NEEDLESS_LIFETIMES, complexity, @@ -46,9 +52,15 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust + /// // Bad: unnecessary lifetimes /// fn unused_lifetime<'a>(x: u8) { /// // .. /// } + /// + /// // Good + /// fn no_lifetime(x: u8) { + /// // ... + /// } /// ``` pub EXTRA_UNUSED_LIFETIMES, complexity, From c6e6b292bd194660bbc42fa60447e0d35c46004b Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Tue, 19 Nov 2019 20:14:09 +0100 Subject: [PATCH 2/2] add a good example for the approx_const lint --- clippy_lints/src/approx_const.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index fac75cffeba6..9f665a3361da 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -23,7 +23,13 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust + /// // Bad /// let x = 3.14; + /// let y = 1_f64 / x; + /// + /// // Good + /// let x = std::f32::consts::PI; + /// let y = std::f64::consts::FRAC_1_PI; /// ``` pub APPROX_CONSTANT, correctness,