Rollup merge of #4832 - dario23:i4829, r=phansch

Add some positive examples to lint docs

fixes #4829
changelog: Add some positive examples to lint docs
This commit is contained in:
Phil Hansch 2019-11-28 10:19:04 +01:00 committed by GitHub
commit 6686892cbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

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

View File

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