Skip to content

Commit 6686892

Browse files
authored
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
2 parents d377486 + c6e6b29 commit 6686892

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clippy_lints/src/approx_const.rs

+6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ declare_clippy_lint! {
2323
///
2424
/// **Example:**
2525
/// ```rust
26+
/// // Bad
2627
/// let x = 3.14;
28+
/// let y = 1_f64 / x;
29+
///
30+
/// // Good
31+
/// let x = std::f32::consts::PI;
32+
/// let y = std::f64::consts::FRAC_1_PI;
2733
/// ```
2834
pub APPROX_CONSTANT,
2935
correctness,

clippy_lints/src/lifetimes.rs

+12
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)