File tree 6 files changed +14
-10
lines changed
6 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -23,11 +23,11 @@ declare_clippy_lint! {
23
23
///
24
24
/// **Example:**
25
25
/// ```rust
26
- /// // Bad
27
26
/// let x = 3.14;
28
27
/// let y = 1_f64 / x;
29
- ///
30
- /// // Good
28
+ /// ```
29
+ /// Use predefined constants instead:
30
+ /// ```rust
31
31
/// let x = std::f32::consts::PI;
32
32
/// let y = std::f64::consts::FRAC_1_PI;
33
33
/// ```
Original file line number Diff line number Diff line change @@ -11,16 +11,14 @@ declare_clippy_lint! {
11
11
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.
12
12
///
13
13
/// **Why is this bad?** Will be optimized out by the compiler or should probably be replaced by a
14
- /// panic!() or unreachable!()
14
+ /// ` panic!()` or ` unreachable!()`
15
15
///
16
16
/// **Known problems:** None
17
17
///
18
18
/// **Example:**
19
19
/// ```rust,ignore
20
20
/// assert!(false)
21
- /// // or
22
21
/// assert!(true)
23
- /// // or
24
22
/// const B: bool = false;
25
23
/// assert!(B)
26
24
/// ```
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ declare_clippy_lint! {
35
35
/// **Known problems:** None.
36
36
///
37
37
/// **Example:**
38
- /// ```ignore
38
+ /// ```rust, ignore
39
39
/// if { let x = somefunc(); x } {}
40
40
/// // or
41
41
/// if somefunc(|x| { x == 47 }) {}
Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ declare_clippy_lint! {
51
51
///
52
52
/// **Example:**
53
53
/// ```rust,ignore
54
- /// if x == true {} // could be `if x { }`
54
+ /// if x == true {}
55
+ /// if y == false {}
56
+ /// ```
57
+ /// use `x` directly:
58
+ /// ```rust,ignore
59
+ /// if x {}
60
+ /// if !y {}
55
61
/// ```
56
62
pub BOOL_COMPARISON ,
57
63
complexity,
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ declare_clippy_lint! {
54
54
/// a = b;
55
55
/// b = a;
56
56
/// ```
57
- /// Could be written as :
57
+ /// If swapping is intended, use `swap()` instead :
58
58
/// ```rust
59
59
/// # let mut a = 1;
60
60
/// # let mut b = 2;
Original file line number Diff line number Diff line change @@ -1642,7 +1642,7 @@ declare_clippy_lint! {
1642
1642
/// **Example:**
1643
1643
///
1644
1644
/// ```rust
1645
- /// let vec: Vec<isize> = vec![] ;
1645
+ /// let vec: Vec<isize> = Vec::new() ;
1646
1646
/// if vec.len() <= 0 {}
1647
1647
/// if 100 > std::i32::MAX {}
1648
1648
/// ```
You can’t perform that action at this time.
0 commit comments