|
1 | | -mod checked_arith_unwrap_or; |
| 1 | +mod manual_saturating_arithmetic; |
2 | 2 | mod option_map_unwrap_or; |
3 | 3 | mod unnecessary_filter_map; |
4 | 4 |
|
@@ -994,15 +994,17 @@ declare_clippy_lint! { |
994 | 994 | /// ```rust |
995 | 995 | /// let x: u32 = 100; |
996 | 996 | /// |
997 | | - /// let add = x.checked_add(y).unwrap_or(u32::max_value()); |
998 | | - /// let sub = x.checked_sub(y).unwrap_or(u32::min_value()); |
| 997 | + /// let add = x.checked_add(3).unwrap_or(u32::max_value()); |
| 998 | + /// let sub = x.checked_sub(3).unwrap_or(u32::min_value()); |
999 | 999 | /// ``` |
1000 | 1000 | /// |
1001 | 1001 | /// can be written using dedicated methods for saturating addition/subtraction as: |
1002 | 1002 | /// |
1003 | 1003 | /// ```rust |
1004 | | - /// let add = x.saturating_add(y); |
1005 | | - /// let sub = x.saturating_sub(y); |
| 1004 | + /// let x: u32 = 100; |
| 1005 | + /// |
| 1006 | + /// let add = x.saturating_add(3); |
| 1007 | + /// let sub = x.saturating_sub(3); |
1006 | 1008 | /// ``` |
1007 | 1009 | pub MANUAL_SATURATING_ARITHMETIC, |
1008 | 1010 | style, |
@@ -1102,7 +1104,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { |
1102 | 1104 | ["unwrap_or", arith @ "checked_add"] |
1103 | 1105 | | ["unwrap_or", arith @ "checked_sub"] |
1104 | 1106 | | ["unwrap_or", arith @ "checked_mul"] => { |
1105 | | - checked_arith_unwrap_or::lint(cx, expr, &arg_lists, &arith["checked_".len()..]) |
| 1107 | + manual_saturating_arithmetic::lint(cx, expr, &arg_lists, &arith["checked_".len()..]) |
1106 | 1108 | }, |
1107 | 1109 | _ => {}, |
1108 | 1110 | } |
|
0 commit comments