Skip to content

Commit 98b7e0a

Browse files
committed
Few changes to lint docs and suggestion message
1 parent b741afc commit 98b7e0a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

clippy_lints/src/implicit_saturating_sub.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ declare_clippy_lint! {
1616
/// **Example:**
1717
///
1818
/// ```rust
19-
/// let end = 10;
20-
/// let start = 5;
19+
/// let end: u32 = 10;
20+
/// let start: u32 = 5;
2121
///
22-
/// let mut i = end - start;
22+
/// let mut i: u32 = end - start;
2323
///
2424
/// // Bad
2525
/// if i != 0 {
@@ -28,13 +28,13 @@ declare_clippy_lint! {
2828
/// ```
2929
/// Use instead:
3030
/// ```rust
31-
/// let end = 10;
32-
/// let start = 5;
31+
/// let end: u32 = 10;
32+
/// let start: u32 = 5;
3333
///
34-
/// let mut i = end - start;
34+
/// let mut i: u32 = end - start;
3535
///
3636
/// // Good
37-
/// i.saturating_sub(1);
37+
/// i = i.saturating_sub(1);
3838
/// ```
3939
pub IMPLICIT_SATURATING_SUB,
4040
pedantic,
@@ -81,7 +81,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitSaturatingSub {
8181
expr.span,
8282
"Implicitly performing saturating subtraction",
8383
"try",
84-
format!("{}.saturating_sub({});", var_name, assign_lit.to_string()),
84+
format!("{} = {}.saturating_sub({});", var_name, var_name, assign_lit.to_string()),
8585
applicability
8686
);
8787
}

0 commit comments

Comments
 (0)