Skip to content

Commit

Permalink
Rollup merge of rust-lang#4832 - dario23:i4829, r=phansch
Browse files Browse the repository at this point in the history
Add some positive examples to lint docs

fixes rust-lang#4829
changelog: Add some positive examples to lint docs
  • Loading branch information
phansch authored Nov 28, 2019
2 parents d377486 + c6e6b29 commit 6686892
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 6686892

Please sign in to comment.