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! {
2424 /// let mut a = 5;
2525 /// let b = 0;
2626 /// // ...
27+ /// // Bad
2728 /// a = a + b;
29+ ///
30+ /// // Good
31+ /// a += b;
2832 /// ```
2933 pub ASSIGN_OP_PATTERN ,
3034 style,
Original file line number Diff line number Diff line change @@ -13,10 +13,24 @@ declare_clippy_lint! {
1313 ///
1414 /// **Example:**
1515 /// ```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+ ///
1628 /// # fn foo(bar: usize) {}
17- /// ((0));
29+ /// // Bad
1830 /// foo((0));
19- /// ((1, 2));
31+ ///
32+ /// // Good
33+ /// foo(0);
2034 /// ```
2135 pub DOUBLE_PARENS ,
2236 complexity,
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ declare_clippy_lint! {
2727 /// ```rust
2828 /// fn foo<T: Drop>() {}
2929 /// ```
30+ /// Could be written as:
31+ /// ```rust
32+ /// fn foo() {}
33+ /// ```
3034 pub DROP_BOUNDS ,
3135 correctness,
3236 "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! {
2222 /// ```rust
2323 /// # use std::time::Duration;
2424 /// let dur = Duration::new(5, 0);
25+ ///
26+ /// // Bad
2527 /// let _micros = dur.subsec_nanos() / 1_000;
2628 /// let _millis = dur.subsec_nanos() / 1_000_000;
29+ ///
30+ /// // Good
31+ /// let _micros = dur.subsec_micros();
32+ /// let _millis = dur.subsec_millis();
2733 /// ```
2834 pub DURATION_SUBSEC ,
2935 complexity,
Original file line number Diff line number Diff line change @@ -25,31 +25,47 @@ declare_clippy_lint! {
2525 /// BattenbergCake,
2626 /// }
2727 /// ```
28+ /// Could be written as:
29+ /// ```rust
30+ /// enum Cake {
31+ /// BlackForest,
32+ /// Hummingbird,
33+ /// Battenberg,
34+ /// }
35+ /// ```
2836 pub ENUM_VARIANT_NAMES ,
2937 style,
3038 "enums where all variants share a prefix/postfix"
3139}
3240
3341declare_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.
3644 ///
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,
3846 /// not repeat the enumeration name.
3947 ///
4048 /// **Known problems:** None.
4149 ///
4250 /// **Example:**
4351 /// ```rust
44- /// enum Cake {
52+ /// pub enum Cake {
4553 /// BlackForestCake,
4654 /// HummingbirdCake,
4755 /// BattenbergCake,
4856 /// }
4957 /// ```
58+ /// Could be written as:
59+ /// ```rust
60+ /// pub enum Cake {
61+ /// BlackForest,
62+ /// Hummingbird,
63+ /// Battenberg,
64+ /// }
65+ /// ```
5066 pub PUB_ENUM_VARIANT_NAMES ,
5167 pedantic,
52- "enums where all variants share a prefix/postfix"
68+ "public enums where all variants share a prefix/postfix"
5369}
5470
5571declare_clippy_lint ! {
@@ -66,6 +82,12 @@ declare_clippy_lint! {
6682 /// struct BlackForestCake;
6783 /// }
6884 /// ```
85+ /// Could be written as:
86+ /// ```rust
87+ /// mod cake {
88+ /// struct BlackForest;
89+ /// }
90+ /// ```
6991 pub MODULE_NAME_REPETITIONS ,
7092 pedantic,
7193 "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! {
3939 ///
4040 /// **Example:**
4141 /// ```ignore
42+ /// // Bad
4243 /// &x == y
44+ ///
45+ /// // Good
46+ /// x == *y
4347 /// ```
4448 pub OP_REF ,
4549 style,
Original file line number Diff line number Diff line change @@ -28,9 +28,16 @@ declare_clippy_lint! {
2828 /// **Example:**
2929 /// ```rust
3030 /// # fn foo(bar: usize) {}
31+ ///
32+ /// // Bad
3133 /// let x = Box::new(1);
3234 /// foo(*x);
3335 /// println!("{}", *x);
36+ ///
37+ /// // Good
38+ /// let x = 1;
39+ /// foo(x);
40+ /// println!("{}", x);
3441 /// ```
3542 pub BOXED_LOCAL ,
3643 perf,
Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ declare_clippy_lint! {
2626 ///
2727 /// **Example:**
2828 /// ```rust,ignore
29+ /// // Bad
2930 /// xs.map(|x| foo(x))
31+ ///
32+ /// // Good
33+ /// foo(xs)
3034 /// ```
3135 /// where `foo(_)` is a plain function that takes the exact argument type of
3236 /// `x`.
Original file line number Diff line number Diff line change @@ -21,11 +21,17 @@ declare_clippy_lint! {
2121 /// **Example:**
2222 /// ```rust
2323 /// let mut x = 0;
24+ ///
25+ /// // Bad
2426 /// let a = {
2527 /// x = 1;
2628 /// 1
2729 /// } + x;
2830 /// // Unclear whether a is 1 or 2.
31+ ///
32+ /// // Good
33+ /// x = 1;
34+ /// let a = 1 + x;
2935 /// ```
3036 pub EVAL_ORDER_DEPENDENCE ,
3137 complexity,
You can’t perform that action at this time.
0 commit comments