File tree Expand file tree Collapse file tree 9 files changed +78
-7
lines changed Expand file tree Collapse file tree 9 files changed +78
-7
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,11 @@ declare_clippy_lint! {
24
24
/// let mut a = 5;
25
25
/// let b = 0;
26
26
/// // ...
27
+ /// // Bad
27
28
/// a = a + b;
29
+ ///
30
+ /// // Good
31
+ /// a += b;
28
32
/// ```
29
33
pub ASSIGN_OP_PATTERN ,
30
34
style,
Original file line number Diff line number Diff line change @@ -13,10 +13,24 @@ declare_clippy_lint! {
13
13
///
14
14
/// **Example:**
15
15
/// ```rust
16
+ /// // Bad
17
+ /// fn simple_double_parens() -> i32 {
18
+ /// ((0))
19
+ /// }
20
+ ///
21
+ /// // Good
22
+ /// fn simple_no_parens() -> i32 {
23
+ /// 0
24
+ /// }
25
+ ///
26
+ /// // or
27
+ ///
16
28
/// # fn foo(bar: usize) {}
17
- /// ((0));
29
+ /// // Bad
18
30
/// foo((0));
19
- /// ((1, 2));
31
+ ///
32
+ /// // Good
33
+ /// foo(0);
20
34
/// ```
21
35
pub DOUBLE_PARENS ,
22
36
complexity,
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ declare_clippy_lint! {
27
27
/// ```rust
28
28
/// fn foo<T: Drop>() {}
29
29
/// ```
30
+ /// Could be written as:
31
+ /// ```rust
32
+ /// fn foo() {}
33
+ /// ```
30
34
pub DROP_BOUNDS ,
31
35
correctness,
32
36
"Bounds of the form `T: Drop` are useless"
Original file line number Diff line number Diff line change @@ -22,8 +22,14 @@ declare_clippy_lint! {
22
22
/// ```rust
23
23
/// # use std::time::Duration;
24
24
/// let dur = Duration::new(5, 0);
25
+ ///
26
+ /// // Bad
25
27
/// let _micros = dur.subsec_nanos() / 1_000;
26
28
/// let _millis = dur.subsec_nanos() / 1_000_000;
29
+ ///
30
+ /// // Good
31
+ /// let _micros = dur.subsec_micros();
32
+ /// let _millis = dur.subsec_millis();
27
33
/// ```
28
34
pub DURATION_SUBSEC ,
29
35
complexity,
Original file line number Diff line number Diff line change @@ -25,31 +25,47 @@ declare_clippy_lint! {
25
25
/// BattenbergCake,
26
26
/// }
27
27
/// ```
28
+ /// Could be written as:
29
+ /// ```rust
30
+ /// enum Cake {
31
+ /// BlackForest,
32
+ /// Hummingbird,
33
+ /// Battenberg,
34
+ /// }
35
+ /// ```
28
36
pub ENUM_VARIANT_NAMES ,
29
37
style,
30
38
"enums where all variants share a prefix/postfix"
31
39
}
32
40
33
41
declare_clippy_lint ! {
34
- /// **What it does:** Detects enumeration variants that are prefixed or suffixed
35
- /// by the same characters.
42
+ /// **What it does:** Detects public enumeration variants that are
43
+ /// prefixed or suffixed by the same characters.
36
44
///
37
- /// **Why is this bad?** Enumeration variant names should specify their variant,
45
+ /// **Why is this bad?** Public enumeration variant names should specify their variant,
38
46
/// not repeat the enumeration name.
39
47
///
40
48
/// **Known problems:** None.
41
49
///
42
50
/// **Example:**
43
51
/// ```rust
44
- /// enum Cake {
52
+ /// pub enum Cake {
45
53
/// BlackForestCake,
46
54
/// HummingbirdCake,
47
55
/// BattenbergCake,
48
56
/// }
49
57
/// ```
58
+ /// Could be written as:
59
+ /// ```rust
60
+ /// pub enum Cake {
61
+ /// BlackForest,
62
+ /// Hummingbird,
63
+ /// Battenberg,
64
+ /// }
65
+ /// ```
50
66
pub PUB_ENUM_VARIANT_NAMES ,
51
67
pedantic,
52
- "enums where all variants share a prefix/postfix"
68
+ "public enums where all variants share a prefix/postfix"
53
69
}
54
70
55
71
declare_clippy_lint ! {
@@ -66,6 +82,12 @@ declare_clippy_lint! {
66
82
/// struct BlackForestCake;
67
83
/// }
68
84
/// ```
85
+ /// Could be written as:
86
+ /// ```rust
87
+ /// mod cake {
88
+ /// struct BlackForest;
89
+ /// }
90
+ /// ```
69
91
pub MODULE_NAME_REPETITIONS ,
70
92
pedantic,
71
93
"type names prefixed/postfixed with their containing module's name"
Original file line number Diff line number Diff line change @@ -39,7 +39,11 @@ declare_clippy_lint! {
39
39
///
40
40
/// **Example:**
41
41
/// ```ignore
42
+ /// // Bad
42
43
/// &x == y
44
+ ///
45
+ /// // Good
46
+ /// x == *y
43
47
/// ```
44
48
pub OP_REF ,
45
49
style,
Original file line number Diff line number Diff line change @@ -28,9 +28,16 @@ declare_clippy_lint! {
28
28
/// **Example:**
29
29
/// ```rust
30
30
/// # fn foo(bar: usize) {}
31
+ ///
32
+ /// // Bad
31
33
/// let x = Box::new(1);
32
34
/// foo(*x);
33
35
/// println!("{}", *x);
36
+ ///
37
+ /// // Good
38
+ /// let x = 1;
39
+ /// foo(x);
40
+ /// println!("{}", x);
34
41
/// ```
35
42
pub BOXED_LOCAL ,
36
43
perf,
Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ declare_clippy_lint! {
26
26
///
27
27
/// **Example:**
28
28
/// ```rust,ignore
29
+ /// // Bad
29
30
/// xs.map(|x| foo(x))
31
+ ///
32
+ /// // Good
33
+ /// foo(xs)
30
34
/// ```
31
35
/// where `foo(_)` is a plain function that takes the exact argument type of
32
36
/// `x`.
Original file line number Diff line number Diff line change @@ -21,11 +21,17 @@ declare_clippy_lint! {
21
21
/// **Example:**
22
22
/// ```rust
23
23
/// let mut x = 0;
24
+ ///
25
+ /// // Bad
24
26
/// let a = {
25
27
/// x = 1;
26
28
/// 1
27
29
/// } + x;
28
30
/// // Unclear whether a is 1 or 2.
31
+ ///
32
+ /// // Good
33
+ /// x = 1;
34
+ /// let a = 1 + x;
29
35
/// ```
30
36
pub EVAL_ORDER_DEPENDENCE ,
31
37
complexity,
You can’t perform that action at this time.
0 commit comments